]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/macros/jcorran/DrawSpectra.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / jcorran / DrawSpectra.C
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 //Draws jet-spectra,pt dependences, centrality dependcies, etc for output of AliAnalysisTaskDiHardron
16 //Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
17
18
19
20
21 #ifndef __CINT__
22 #include <TF1.h>
23 #include <TF2.h>
24 #include "TSystem.h"
25 #include <iostream>
26 #include <TH1.h>
27 #include <TH2.h>
28 #include <TH3.h>
29 #include <TRandom.h>
30 #include <fstream>
31 #include "TList.h"
32 #include "TArrayF.h"
33 #endif
34
35 void DrawSpectra(){
36   gROOT->Reset();
37   gROOT->LoadMacro("Util9.C");
38   Style(1);
39   gStyle->SetOptFit(1);
40   //Parameters to be changed
41   Int_t APtTPtMult=0;//0 Associated particle spectra, 1 Trigger particle dependence, 2 Centrality dependence
42   Float_t TPt1=4;
43   Float_t TPt2=6;
44   Float_t APt1=0.25;
45   Float_t APt2=2;
46   Float_t Mult1=0;
47   Float_t Mult2=0;
48   Int_t PtWeighted=0;
49   Int_t HorizontalErrors=0;
50   Int_t NoTitle=1;
51   Int_t DrawFit=1;
52   Int_t LSign=0;
53   Int_t SaveFits=1;
54   int EffMethod=0;//0 no correction, 1 angle dependent, 2 use mix for triggered, 3 <1> 
55   char *filetype=".gif"; //.gif, .eps etc...
56   // const Int_t nTPt=12;
57   //Float_t TPtBins[(nTPt+1)]={2.5,3,4,6,8,10,15,20,30,40,50,75,100};
58   /*
59   const Int_t nTPt=6;
60   Float_t TPtBins[(nTPt+1)]={2,2.5,3,4,6,10,20};
61   */
62   
63   //  const Int_t nTPt=11;
64   //Float_t TPtBins[(nTPt+1)]={2,2.5,3,4,5,6,8,10,15,20,30,50};
65    const Int_t nTPt=9;
66    Float_t TPtBins[(nTPt+1)]={2,2.5,3,4,5,6,8,10,15,20};
67    // const Int_t nAPt=30;
68    // 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};
69   // const Int_t nAPt=17;//up to 15-20 for 7 TeV
70   // 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};
71   // const Int_t nAPt=4;//from  20-30 for 7 TeV
72   //Float_t APtBins[(nAPt+1)]={0.25,1,2,4,30};
73   //const Int_t nAPt=9;
74   // Float_t APtBins[(nAPt+1)]={0.25,0.5,1,1.5,2,2.5,3,3.5,4,6};
75   const Int_t nAPt=6;
76   Float_t APtBins[(nAPt+1)]={0.25,0.5,0.75,1,2,3,4};
77   const Int_t nMult=2;
78   Float_t MultBins1[nMult]={1,2};
79   Float_t MultBins2[nMult]={1,2};
80   Float_t MultArray1[3]={0,0,20};//>=
81   Float_t MultArray2[3]={500,20,500};//<
82   Float_t ZYAMCent=1.5;
83   Float_t ZYAMWidth=0.2;
84   float Pi=3.1415926535898;
85   Float_t NearWidthPhi=1.5;
86   Float_t AwayWidthPhi=Pi-NearWidthPhi;
87   Float_t NearWidthEta=0.5;
88
89   // char *Folder="2009-09-30/v4-16-Rev-08/pdc1_resdb_100_0000";
90   // char *EffFolder="2009-09-30/v4-16-Rev-08/pdc1_resdb_100_0000";
91   //char *Folder="current/7";
92   //  char *EffFolder="current/7";
93   //char *Folder="2009-12-15/RealData";//LHC09b8
94   // char *EffFolder="2009-12-03/Combined900";
95   // char *Folder="2010-01-06/900Data";//LHC09b8
96   // char *Folder="2010-03-10/pass5";
97   // char *EffFolder="2010-03-10/all_5";
98   // char *Folder="2010-04-12/pass5";
99   //  char *EffFolder="2010-04-12/900Pythia";
100   /*
101   char *Folder="2010-08-17/LHC10b_7pass2";
102   char *EffFolder="2010-08-17/7Pythia_LHC10b5";
103   */
104   
105   char *Folder="2010-08-17/LHC10c_900pass2";
106   //char *Folder="2010-07-02/LHC10c6_900Pythia";
107    char *EffFolder="2010-08-17/LHC10c6_900Pythia";
108   
109
110  //Plotting 
111   Float_t MarkerSize=1.5;
112   Int_t ColorNearPhi=kBlack;
113   Int_t ColorAwayPhi=kRed;
114   Int_t ColorMin=kGreen+2;
115   Int_t ColorNearPhiFit=kBlue+2;
116   Int_t ColorAwayPhiFit=kRed+2;
117   Int_t ColorMinFit=kGreen+3;
118   Int_t ColorNearEta=kGreen+2;
119   Int_t ColorAwayEta=kMagenta+3;
120   Int_t ColorNearEtaFit=kGreen+3;
121   Int_t MarkerNearPhi=20;
122   Int_t MarkerAwayPhi=21;
123   Int_t MarkerMin=22;
124   Int_t MarkerNearPhiFit=24;
125   Int_t MarkerAwayPhiFit=25;
126   Int_t MarkerMinFit=26;
127   Int_t MarkerNearEta=29;
128   Int_t MarkerAwayEta=23;
129   Int_t MarkerNearEtaFit=30;
130   
131   
132   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]");
133   fit1->SetParameters(.1,.2,.1,.35,.1);
134   fit1->SetParNames("Near-Yield", "Near-Width","Away-Yield","Away-Width","Bg-Level");
135   fit1->SetParLimits(0,1E-10,100);
136   fit1->SetParLimits(1,0.01,6);
137   fit1->SetParLimits(2,1E-10,100);
138   fit1->SetParLimits(3,0.01,6);
139   fit1->SetParLimits(4,1E-10,500);
140    TF1 *fit2=new TF1("fit2","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))))+[2]");
141   fit2->SetParameters(.1,.2,.1);
142   fit2->SetParNames("Near-Yield", "Near-Width","Bg-Level");
143   fit2->SetParLimits(0,1E-10,100);
144   fit2->SetParLimits(1,0.01,6);
145   fit2->SetParLimits(2,1E-10,500);
146   //Bollow this users should not need to change
147   char *cPt[2]={"","PT"};
148   char name[250];
149   char inName[100];
150   char effName[100];
151   sprintf(inName,"%s/julery_DiHadron.root",Folder);
152   sprintf(effName,"%s/julery_DiHadron.root",EffFolder);
153   cout << inName << endl;
154   cout << effName << endl;
155   Float_t MPt[3];//<pt>, error <pt>, # of triggers
156   Float_t MPt2[3];
157   Float_t TrigSum=0;
158   
159   TH1F *hPhiRaw=new TH1F("hPhiRaw","",1,0,1);
160   TH1F *hPhiCorr=new TH1F("hPhiCorr","",1,0,1);
161   TH1F *hPhiEff=new TH1F("hPhiEff","",1,0,1);
162   TH1F *hPhiMC=new TH1F("hPhiMC","",1,0,1);
163   TH1F *hPhiMixRaw=new TH1F("hPhiMixRaw","",1,0,1);
164   TH1F *hPhiMixCorr=new TH1F("hPhiMixCorr","",1,0,1);
165   TH1F *hPhiMixEff=new TH1F("hPhiMixEff","",1,0,1);
166   TH1F *hPhiMixMC=new TH1F("hPhiMixMC","",1,0,1);
167   TH2F *hPhiEtaRaw=new TH2F("hPhiEtaRaw","",1,0,1,1,0,1);
168   TH2F *hPhiEtaCorr=new TH2F("hPhiEtaCorr","",1,0,1,1,0,1);
169   TH2F *hPhiEtaEff=new TH2F("hPhiEtaEff","",1,0,1,1,0,1);
170   TH2F *hPhiEtaMC=new TH2F("hPhiEtaMC","",1,0,1,1,0,1);
171   TH2F *hPhiEtaMixRaw=new TH2F("hPhiEtaMixRaw","",1,0,1,1,0,1);
172   TH2F *hPhiEtaMixCorr=new TH2F("hPhiEtaMixCorr","",1,0,1,1,0,1);
173   TH2F *hPhiEtaMixEff=new TH2F("hPhiEtaMixEff","",1,0,1,1,0,1);
174   TH2F *hPhiEtaMixMC=new TH2F("hPhiEtaMixMC","",1,0,1,1,0,1);
175
176   TH1F *hEtaNRaw=new TH1F("hEtaNRaw","",1,0,1);
177   TH1F *hEtaNCorr=new TH1F("hEtaNCorr","",1,0,1);
178   TH1F *hEtaNEff=new TH1F("hEtaNEff","",1,0,1);
179   TH1F *hEtaNMC=new TH1F("hEtaNMC","",1,0,1);
180   TH1F *hEtaNMixRaw=new TH1F("hEtaNMixRaw","",1,0,1);
181   TH1F *hEtaNMixCorr=new TH1F("hEtaNMixCorr","",1,0,1);
182   TH1F *hEtaNMixEff=new TH1F("hEtaNMixEff","",1,0,1);
183   TH1F *hEtaNMixMC=new TH1F("hEtaNMixMC","",1,0,1);
184
185   TH1F *hEtaARaw=new TH1F("hEtaARaw","",1,0,1);
186   TH1F *hEtaACorr=new TH1F("hEtaACorr","",1,0,1);
187   TH1F *hEtaAEff=new TH1F("hEtaAEff","",1,0,1);
188   TH1F *hEtaAMC=new TH1F("hEtaAMC","",1,0,1);
189   TH1F *hEtaAMixRaw=new TH1F("hEtaAMixRaw","",1,0,1);
190   TH1F *hEtaAMixCorr=new TH1F("hEtaAMixCorr","",1,0,1);
191   TH1F *hEtaAMixEff=new TH1F("hEtaAMixEff","",1,0,1);
192   TH1F *hEtaAMixMC=new TH1F("hEtaAMixMC","",1,0,1);
193   
194   TH1F *hTPhiRaw=new TH1F("hTPhiRaw","For near-side pt sum",1,0,1);
195   TH1F *hTPhiCorr=new TH1F("hTPhiCorr","",1,0,1);
196   TH1F *hTPhiEff=new TH1F("hTPhiErr","",1,0,1);
197   TH1F *hTPhiMC=new TH1F("hTPhiMC","",1,0,1);
198   TH1F *hTPhiMixRaw=new TH1F("hTPhiMixRaw","",1,0,1);
199   TH1F *hTPhiMixCorr=new TH1F("hTPhiMixCorr","",1,0,1);
200   TH1F *hTPhiMixEff=new TH1F("hTPhiMixEff","",1,0,1);
201   TH1F *hTPhiMixMC=new TH1F("hTPhiMixMC","",1,0,1);
202   TH2F *hTPhiEtaRaw=new TH2F("hTPhiEtaRaw","",1,0,1,1,0,1);
203   TH2F *hTPhiEtaCorr=new TH2F("hTPhiEtaCorr","",1,0,1,1,0,1);
204   TH2F *hTPhiEtaEff=new TH2F("hTPhiEtaEff","",1,0,1,1,0,1);
205   TH2F *hTPhiEtaMC=new TH2F("hTPhiEtaMC","",1,0,1,1,0,1);
206   TH2F *hTPhiEtaMixRaw=new TH2F("hTPhiEtaMixRaw","",1,0,1,1,0,1);
207   TH2F *hTPhiEtaMixCorr=new TH2F("hTPhiEtaMixCorr","",1,0,1,1,0,1);
208   TH2F *hTPhiEtaMixEff=new TH2F("hTPhiEtaMixEff","",1,0,1,1,0,1);
209   TH2F *hTPhiEtaMixMC=new TH2F("hTPhiEtaMixMC","",1,0,1,1,0,1);
210
211   TH1F *hTEtaNRaw=new TH1F("hTEtaNRaw","",1,0,1);
212   TH1F *hTEtaNCorr=new TH1F("hTEtaNCorr","",1,0,1);
213   TH1F *hTEtaNEff=new TH1F("hTEtaNEff","",1,0,1);
214   TH1F *hTEtaNMC=new TH1F("hTEtaNMC","",1,0,1);
215   TH1F *hTEtaNMixRaw=new TH1F("hTEtaNMixRaw","",1,0,1);
216   TH1F *hTEtaNMixCorr=new TH1F("hTEtaNMixCorr","",1,0,1);
217   TH1F *hTEtaNMixEff=new TH1F("hTEtaNMixEff","",1,0,1);
218   TH1F *hTEtaNMixMC=new TH1F("hTEtaNMixMC","",1,0,1);
219
220   TH1F *hTEtaARaw=new TH1F("hTEtaARaw","",1,0,1);
221   TH1F *hTEtaACorr=new TH1F("hTEtaACorr","",1,0,1);
222   TH1F *hTEtaAEff=new TH1F("hTEtaAEff","",1,0,1);
223   TH1F *hTEtaAMC=new TH1F("hTEtaAMC","",1,0,1);
224   TH1F *hTEtaAMixRaw=new TH1F("hTEtaAMixRaw","",1,0,1);
225   TH1F *hTEtaAMixCorr=new TH1F("hTEtaAMixCorr","",1,0,1);
226   TH1F *hTEtaAMixEff=new TH1F("hTEtaAMixEff","",1,0,1);
227   TH1F *hTEtaAMixMC=new TH1F("hTEtaAMixMC","",1,0,1);
228   
229   TH1F *hPhiRawPt=new TH1F("hPhiRawPt","",1,0,1);
230   TH1F *hPhiCorrPt=new TH1F("hPhiCorrPt","",1,0,1);
231   TH1F *hPhiEffPt=new TH1F("hPhiEffPt","",1,0,1);
232   TH1F *hPhiMCPt=new TH1F("hPhiMCPt","",1,0,1);
233   TH1F *hPhiMixRawPt=new TH1F("hPhiMixRawPt","",1,0,1);
234   TH1F *hPhiMixCorrPt=new TH1F("hPhiMixCorrPt","",1,0,1);
235   TH1F *hPhiMixEffPt=new TH1F("hPhiMixEffPt","",1,0,1);
236   TH1F *hPhiMixMCPt=new TH1F("hPhiMixMCPt","",1,0,1);
237   TH2F *hPhiEtaRawPt=new TH2F("hPhiEtaRawPt","",1,0,1,1,0,1);
238   TH2F *hPhiEtaCorrPt=new TH2F("hPhiEtaCorrPt","",1,0,1,1,0,1);
239   TH2F *hPhiEtaEffPt=new TH2F("hPhiEtaEffPt","",1,0,1,1,0,1);
240   TH2F *hPhiEtaMCPt=new TH2F("hPhiEtaMCPt","",1,0,1,1,0,1);
241   TH2F *hPhiEtaMixRawPt=new TH2F("hPhiEtaMixRawPt","",1,0,1,1,0,1);
242   TH2F *hPhiEtaMixCorrPt=new TH2F("hPhiEtaMixCorrPt","",1,0,1,1,0,1);
243   TH2F *hPhiEtaMixEffPt=new TH2F("hPhiEtaMixEffPt","",1,0,1,1,0,1);
244   TH2F *hPhiEtaMixMCPt=new TH2F("hPhiEtaMixMCPt","",1,0,1,1,0,1);
245
246   TH1F *hEtaNRawPt=new TH1F("hEtaNRawPt","",1,0,1);
247   TH1F *hEtaNCorrPt=new TH1F("hEtaNCorrPt","",1,0,1);
248   TH1F *hEtaNEffPt=new TH1F("hEtaNEffPt","",1,0,1);
249   TH1F *hEtaNMCPt=new TH1F("hEtaNMCPt","",1,0,1);
250   TH1F *hEtaNMixRawPt=new TH1F("hEtaNMixRawPt","",1,0,1);
251   TH1F *hEtaNMixCorrPt=new TH1F("hEtaNMixCorrPt","",1,0,1);
252   TH1F *hEtaNMixEffPt=new TH1F("hEtaNMixEffPt","",1,0,1);
253   TH1F *hEtaNMixMCPt=new TH1F("hEtaNMixMCPt","",1,0,1);
254
255   TH1F *hEtaARawPt=new TH1F("hEtaARawPt","",1,0,1);
256   TH1F *hEtaACorrPt=new TH1F("hEtaACorrPt","",1,0,1);
257   TH1F *hEtaAEffPt=new TH1F("hEtaAEffPt","",1,0,1);
258   TH1F *hEtaAMCPt=new TH1F("hEtaAMCPt","",1,0,1);
259   TH1F *hEtaAMixRawPt=new TH1F("hEtaAMixRawPt","",1,0,1);
260   TH1F *hEtaAMixCorrPt=new TH1F("hEtaAMixCorrPt","",1,0,1);
261   TH1F *hEtaAMixEffPt=new TH1F("hEtaAMixEffPt","",1,0,1);
262   TH1F *hEtaAMixMCPt=new TH1F("hEtaAMixMCPt","",1,0,1);
263   
264   TH1F *hTPhiRawPt=new TH1F("hTPhiRawPt","",1,0,1);
265   TH1F *hTPhiCorrPt=new TH1F("hTPhiCorrPt","",1,0,1);
266   TH1F *hTPhiEffPt=new TH1F("hTPhiEffPt","",1,0,1);
267   TH1F *hTPhiMCPt=new TH1F("hTPhiMCPt","",1,0,1);
268   TH1F *hTPhiMixRawPt=new TH1F("hTPhiMixRawPt","",1,0,1);
269   TH1F *hTPhiMixCorrPt=new TH1F("hTPhiMixCorrPt","",1,0,1);
270   TH1F *hTPhiMixEffPt=new TH1F("hTPhiMixEffPt","",1,0,1);
271   TH1F *hTPhiMixMCPt=new TH1F("hTPhiMixMCPt","",1,0,1);
272   TH2F *hTPhiEtaRawPt=new TH2F("hTPhiEtaRawPt","",1,0,1,1,0,1);
273   TH2F *hTPhiEtaCorrPt=new TH2F("hTPhiEtaCorrPt","",1,0,1,1,0,1);
274   TH2F *hTPhiEtaEffPt=new TH2F("hTPhiEtaEffPt","",1,0,1,1,0,1);
275   TH2F *hTPhiEtaMCPt=new TH2F("hTPhiEtaMCPt","",1,0,1,1,0,1);
276   TH2F *hTPhiEtaMixRawPt=new TH2F("hTPhiEtaMixRawPt","",1,0,1,1,0,1);
277   TH2F *hTPhiEtaMixCorrPt=new TH2F("hTPhiEtaMixCorrPt","",1,0,1,1,0,1);
278   TH2F *hTPhiEtaMixEffPt=new TH2F("hTPhiEtaMixEffPt","",1,0,1,1,0,1);
279   TH2F *hTPhiEtaMixMCPt=new TH2F("hTPhiEtaMixMCPt","",1,0,1,1,0,1);
280
281   TH1F *hTEtaNRawPt=new TH1F("hTEtaNRawPt","",1,0,1);
282   TH1F *hTEtaNCorrPt=new TH1F("hTEtaNCorrPt","",1,0,1);
283   TH1F *hTEtaNEffPt=new TH1F("hTEtaNEffPt","",1,0,1);
284   TH1F *hTEtaNMCPt=new TH1F("hTEtaNMCPt","",1,0,1);
285   TH1F *hTEtaNMixRawPt=new TH1F("hTEtaNMixRawPt","",1,0,1);
286   TH1F *hTEtaNMixCorrPt=new TH1F("hTEtaNMixCorrPt","",1,0,1);
287   TH1F *hTEtaNMixEffPt=new TH1F("hTEtaNMixEffPt","",1,0,1);
288   TH1F *hTEtaNMixMCPt=new TH1F("hTEtaNMixMCPt","",1,0,1);
289
290   TH1F *hTEtaARawPt=new TH1F("hTEtaARawPt","",1,0,1);
291   TH1F *hTEtaACorrPt=new TH1F("hTEtaACorrPt","",1,0,1);
292   TH1F *hTEtaAEffPt=new TH1F("hTEtaAEffPt","",1,0,1);
293   TH1F *hTEtaAMCPt=new TH1F("hTEtaAMCPt","",1,0,1);
294   TH1F *hTEtaAMixRawPt=new TH1F("hTEtaAMixRawPt","",1,0,1);
295   TH1F *hTEtaAMixCorrPt=new TH1F("hTEtaAMixCorrPt","",1,0,1);
296   TH1F *hTEtaAMixEffPt=new TH1F("hTEtaAMixEffPt","",1,0,1);
297   TH1F *hTEtaAMixMCPt=new TH1F("hTEtaAMixMCPt","",1,0,1);
298   
299   TH1F *hMult=new TH1F("hMult","",1,0,1);
300   TH1F *hMultTrig=new TH1F("hMultTrig","",1,0,1);
301   TH1F *hMult2=new TH1F("hMult2","",1,0,1);
302   TH1F *hMultTrig2=new TH1F("hMultTrig2","",1,0,1);
303   float plotmin=10,plotmax=11;
304   float plotmin2=10,plotmax2=11;
305   float plotmin3=10,plotmax3=11;
306   
307   //histograms for ZYAM
308   TH1F *hPhiCorr2;
309   TH1F *hPhiMixCorr2;
310   TH1F *hEtaNCorr2;
311   TH1F *hEtaACorr2;
312   TH1F *hEtaMixCorr2;
313   TH2F *hPhiEtaCorr2;
314   TH2F *hPhiEtaMixCorr2;
315   
316   TH1F *hPhiCorrPt2;
317   TH1F *hPhiMixCorrPt2;
318   TH1F *hEtaNCorrPt2;
319   TH1F *hEtaACorrPt2;
320   TH1F *hEtaMixCorr2;
321   TH2F *hPhiEtaCorrPt2;
322   TH2F *hPhiEtaMixCorrPt2;
323   
324   //histograms for summing the centraility bins
325   TH1F *hPhiCorrSum;
326   TH1F *hPhiCorr2Sum;
327   TH1F *hPhiMixCorrSum;
328   TH1F *hPhiMixCorr2Sum;
329   TH1F *hEtaNCorrSum;
330   TH1F *hEtaNCorr2Sum;
331   TH1F *hEtaNMixCorrSum;
332   TH1F *hEtaNMixCorr2Sum;
333   TH1F *hEtaACorrSum;
334   TH1F *hEtaACorr2Sum; 
335   TH1F *hEtaAMixCorrSum;
336   TH1F *hEtaAMixCorr2Sum;
337   TH2F *hPhiEtaCorrSum;
338   TH2F *hPhiEtaCorr2Sum;
339   TH2F *hPhiEtaMixCorrSum;
340   TH2F *hPhiEtaMixCorr2Sum;
341
342   TH1F *hPhiCorrPtSum;
343   TH1F *hPhiCorrPt2Sum;
344   TH1F *hPhiMixCorrPtSum;
345   TH1F *hPhiMixCorrPt2Sum;
346   TH1F *hEtaNCorrPtSum;
347   TH1F *hEtaNCorrPt2Sum;
348   TH1F *hEtaNMixCorrPtSum;
349   TH1F *hEtaNMixCorrPt2Sum;
350   TH1F *hEtaACorrPtSum;
351   TH1F *hEtaACorrPt2Sum;
352   TH1F *hEtaAMixCorrPtSum;
353   TH1F *hEtaAMixCorrPt2Sum;
354   TH2F *hPhiEtaCorrPtSum;
355   TH2F *hPhiEtaCorrPt2Sum;
356   TH2F *hPhiEtaMixCorrPtSum;
357   TH2F *hPhiEtaMixCorrPt2Sum;
358   TH1F *hTPhiCorrPt2Sum;
359   TH2F *hTPhiEtaCorrSum;
360   TH2F *hTPhiEtaCorrPt2Sum;
361   
362   int NearBinsPhi;
363   int AwayBinsPhi;
364   int MinBinsPhi;
365   int NearBinsEta;
366   int AwayBinsEta;
367   int NearBinsPhiEta1;
368   int NearBinsPhiEta2;
369   int AwayBinsPhiEta;
370   int MinBinsPhiEta;
371   float tempsum;
372   
373   TAxis *phiaxis;
374   TAxis *etaaxis;
375   
376   int loopSize=0;
377   int nAPt2=0;
378   for(int i=0;i<=nAPt;i++){if(fabs(TPt1-APtBins[i])<0.2)nAPt2=i;}
379   if(APtTPtMult==0)loopSize=nAPt2;
380   if(APtTPtMult==1)loopSize=nTPt;
381   if(APtTPtMult==2)loopSize=nMult;
382   const int nMainLoop=loopSize;
383   cout << "loopSize " << loopSize << endl;
384   if(loopSize==0){
385     cout << "Error: Check Arrays" << endl;
386     break;
387   }
388   Float_t MainArray[nMainLoop];
389   Float_t eMainArray[nMainLoop];
390   Float_t a[3];
391   float centx, centy;
392   float binwx, binwy;
393   const int nx=18;
394   //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)
395   float NXPhi[nx][nMainLoop];
396   float AXPhi[nx][nMainLoop];
397   float NXPhiFit[nx][nMainLoop];
398   float AXPhiFit[nx][nMainLoop];
399   float NXEta[nx][nMainLoop];
400   float AXEta[nx][nMainLoop];
401   float NXEtaFit[nx][nMainLoop];
402   float AXEtaFit[nx][nMainLoop];
403   float NXPhiEta1[nx][nMainLoop];
404   float NXPhiEta2[nx][nMainLoop];
405   float AXPhiEta[nx][nMainLoop];
406   //arrays for our tgraphs to store yields and averge bin contends
407   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
408   float NYieldPhi[nyields][nMainLoop];
409   float NYieldPhiZYAM[nyields][nMainLoop];
410   float NYieldPhiFit[nyields][nMainLoop];
411   float NYieldEta[nyields][nMainLoop];
412   float NYieldEtaZYAM[nyields][nMainLoop];
413   float NYieldEtaFit[nyields][nMainLoop];
414   float NYieldPhiEta1[nyields][nMainLoop];
415   float NYieldPhiEta2[nyields][nMainLoop];
416   float NYieldPhiEta3[nyields][nMainLoop];//jet only
417   float NYieldPhiEta1ZYAM[nyields][nMainLoop];//Jet+Ridge
418   float NYieldPhiEta2ZYAM[nyields][nMainLoop];//Ridge
419   float NRMSPhi[nyields][nMainLoop];
420   float NRMSEta[nyields][nMainLoop];
421   float NWidthPhi[nyields][nMainLoop];
422   float NWidthEta[nyields][nMainLoop];
423   float NJtPhi[nyields][nMainLoop];
424   float NJtEta[nyields][nMainLoop];
425   float NRMSPhiEtaPhi[nyields][nMainLoop];
426   float NRMSPhiEtaEta[nyields][nMainLoop];
427   float AYieldPhi[nyields][nMainLoop];
428   float AYieldPhiZYAM[nyields][nMainLoop];
429   float AYieldPhiFit[nyields][nMainLoop];
430   float AYieldEta[nyields][nMainLoop];
431   float AYieldEtaZYAM[nyields][nMainLoop];
432   float AYieldEtaFit[nyields][nMainLoop];
433   float AYieldPhiEta[nyields][nMainLoop];
434   float AYieldPhiEtaZYAM[nyields][nMainLoop];
435   float ARMSPhi[nyields][nMainLoop];
436   float ARMSEta[nyields][nMainLoop];
437   float AWidthPhi[nyields][nMainLoop];
438   float AWidthEta[nyields][nMainLoop];
439   float AJtPhi[nyields][nMainLoop];
440   float AJtEta[nyields][nMainLoop];
441   float MYieldPhi[nyields][nMainLoop];
442   float MYieldPhiFit[nyields][nMainLoop];
443   float MYieldPhiEta[nyields][nMainLoop];
444   float MAvePhiEta[nyields][nMainLoop];
445
446   float TNYieldPhi[nyields][nMainLoop];
447   float TNYieldPhiZYAM[nyields][nMainLoop];
448   float TNYieldPhiFit[nyields][nMainLoop];
449   float TNYieldPhiEta1[nyields][nMainLoop];
450   float TNYieldPhiEta2[nyields][nMainLoop];
451   float TNYieldPhiEta3[nyields][nMainLoop];
452   float TAYieldPhi[nyields][nMainLoop];
453   float TAYieldPhiZYAM[nyields][nMainLoop];
454   float TAYieldPhiFit[nyields][nMainLoop];
455   float TAYieldPhiEta[nyields][nMainLoop];
456   float TAYieldPhiEtaZYAM[nyields][nMainLoop];
457
458   float NAvePhi[nyields][nMainLoop];
459   float NAvePhiZYAM[nyields][nMainLoop];
460   float NAvePhiFit[nyields][nMainLoop];
461   float NAveEta[nyields][nMainLoop];
462   float NAveEtaZYAM[nyields][nMainLoop];
463   float NAveEtaFit[nyields][nMainLoop];
464   float NAvePhiEta1[nyields][nMainLoop];
465   float NAvePhiEta2[nyields][nMainLoop];
466   float NAvePhiEta1ZYAM[nyields][nMainLoop];
467   float NAvePhiEta2ZYAM[nyields][nMainLoop];
468   float AAvePhi[nyields][nMainLoop];
469   float AAvePhiZYAM[nyields][nMainLoop];
470   float AAvePhiFit[nyields][nMainLoop];
471   float AAveEta[nyields][nMainLoop];
472   float AAveEtaZYAM[nyields][nMainLoop];
473   float AAveEtaFit[nyields][nMainLoop];
474   float AAvePhiEta[nyields][nMainLoop];
475   float AAvePhiEtaZYAM[nyields][nMainLoop];
476   float MAvePhi[nyields][nMainLoop];
477   float MAvePhiFit[nyields][nMainLoop];
478   float MAvePhiEta[nyields][nMainLoop];
479   float trms1;
480   float trms2;
481   float trms3;
482   TFile *inFile=new TFile(inName);
483   TList *inList=inFile->Get("julery_DiHadron");
484   TFile *effFile=new TFile(effName);
485   TList *effList=effFile->Get("julery_DiHadron");
486   char *FitTit[2]={"","_Fit"};
487   //loop for total near-side yield over full pt range
488   for(int Cent=Mult1;Cent<=Mult2;Cent++){
489  MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,inList,hTPhiRaw,hTPhiMixRaw,hTEtaNRaw,hTEtaNMixRaw,hTEtaARaw,hTEtaAMixRaw,hTPhiEtaRaw,hTPhiEtaMixRaw,MPt,1,0,0,0);
490     MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiEff,hTPhiMixEff,hTEtaNEff,hTEtaNMixEff,hTEtaAEff,hTEtaAMixEff,hTPhiEtaEff,hTPhiEtaMixEff,MPt2,0,0,0,0);
491     MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiMC,hTPhiMixMC,hTEtaNMC,hTEtaNMixMC,hTEtaAMC,hTEtaAMixMC,hTPhiEtaMC,hTPhiEtaMixMC,MPt2,0,1,0,0);
492     MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,inList,hTPhiRawPt,hTPhiMixRawPt,hTEtaNRawPt,hTEtaNMixRawPt,hTEtaARawPt,hTEtaAMixRawPt,hTPhiEtaRawPt,hTPhiEtaMixRawPt,MPt,1,0,0,0);
493     MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiEffPt,hTPhiMixEffPt,hTEtaNEffPt,hTEtaNMixEffPt,hTEtaAEffPt,hTEtaAMixEffPt,hTPhiEtaEffPt,hTPhiEtaMixEffPt,MPt2,1,0,0,0);
494     MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiMCPt,hTPhiMixMCPt,hTEtaNMCPt,hTEtaNMixMCPt,hTEtaAMCPt,hTEtaAMixMCPt,hTPhiEtaMCPt,hTPhiEtaMixMCPt,MPt2,1,1,0,0);
495     // cout << "hTPhiRaw " << hTPhiRaw->GetBinContent(1) << endl;
496  if(EffMethod<4){
497       EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hTPhiEff,hTPhiMC,hTPhiMixEff,hTPhiMixMC,hTEtaNEff,hTEtaNMC,hTEtaNMixEff,hTEtaNMixMC,hTEtaAEff,hTEtaAMC,hTEtaAMixEff,hTEtaAMixMC,hTPhiEtaEff,hTPhiEtaMC,hTPhiEtaMixEff,hTPhiEtaMixMC,EffMethod);
498       EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hTPhiEffPt,hTPhiMCPt,hTPhiMixEffPt,hTPhiMixMCPt,hTEtaNEffPt,hTEtaNMCPt,hTEtaNMixEffPt,hTEtaNMixMCPt,hTEtaAEffPt,hTEtaAMCPt,hTEtaAMixEffPt,hTEtaAMixMCPt,hTPhiEtaEffPt,hTPhiEtaMCPt,hTPhiEtaMixEffPt,hTPhiEtaMixMCPt,EffMethod);
499     }
500     else{
501       EffFit(APt1,APt2,Cent,effList,hTPhiEff,hTPhiMixEff,hTEtaNEff,hTEtaNMixEff,hTEtaAEff,hTEtaAMixEff,hTPhiEtaEff,hTPhiEtaMixEff,LSign,VariablePtLimit);
502       EffFit(APt1,APt2,Cent,effList,hTPhiEffPt,hTPhiMixEffPt,hTEtaNEffPt,hTEtaNMixEffPt,hTEtaAEffPt,hTEtaAMixEffPt,hTPhiEtaEffPt,hTPhiEtaMixEffPt,LSign,VariablePtLimit);
503     }
504     /*
505     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);
506     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);
507     */
508     
509     hTPhiCorr=(TH1F*)hTPhiRaw->Clone();
510     sprintf(name,"hTPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
511     hTPhiCorr->SetName(name);
512     hTPhiCorr->Divide(hTPhiEff);
513     
514     hTPhiMixCorr=(TH1F*)hTPhiMixRaw->Clone();
515     sprintf(name,"hTPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
516     hTPhiMixCorr->SetName(name);
517     hTPhiMixCorr->Divide(hTPhiMixEff);
518
519     hTEtaNCorr=(TH1F*)hTEtaNRaw->Clone();
520     sprintf(name,"hTEtaNCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
521     hTEtaNCorr->SetName(name);
522     hTEtaNCorr->Divide(hTEtaNEff);
523     
524     hTEtaNMixCorr=(TH1F*)hTEtaNMixRaw->Clone();
525     sprintf(name,"hTEtaNMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
526     hTEtaNMixCorr->SetName(name);
527     hTEtaNMixCorr->Divide(hTPhiMixEff);
528
529     hTEtaACorr=(TH1F*)hTEtaARaw->Clone();
530     sprintf(name,"hTEtaACorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
531     hTEtaACorr->SetName(name);
532     hTEtaACorr->Divide(hTEtaAEff);
533     
534     hTEtaAMixCorr=(TH1F*)hTEtaAMixRaw->Clone();
535     sprintf(name,"hTEtaAMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
536     hTEtaAMixCorr->SetName(name);
537     hTEtaAMixCorr->Divide(hTPhiMixEff);
538     
539     hTPhiEtaCorr=(TH2F*)hTPhiEtaRaw->Clone();
540     sprintf(name,"hTPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
541     hTPhiEtaCorr->SetName(name);
542     hTPhiEtaCorr->Divide(hTPhiEtaEff);
543     
544     hTPhiEtaMixCorr=(TH2F*)hTPhiEtaMixRaw->Clone();
545     sprintf(name,"hTPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
546     hTPhiEtaMixCorr->SetName(name);
547     hTPhiEtaMixCorr->Divide(hTPhiEtaMixEff);
548     
549     hTPhiCorrPt=(TH1F*)hTPhiRawPt->Clone();
550     sprintf(name,"hTPhiCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
551     hTPhiCorrPt->SetName(name);
552     hTPhiCorrPt->Divide(hTPhiEffPt);
553     
554     hTPhiMixCorrPt=(TH1F*)hTPhiMixRawPt->Clone();
555     sprintf(name,"hTPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
556     hTPhiMixCorrPt->SetName(name);
557     hTPhiMixCorrPt->Divide(hTPhiMixEffPt);
558
559     hTEtaNCorrPt=(TH1F*)hTEtaNRawPt->Clone();
560     sprintf(name,"hTEtaNCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
561     hTEtaNCorrPt->SetName(name);
562     hTEtaNCorrPt->Divide(hTEtaNEffPt);
563     
564     hTEtaNMixCorrPt=(TH1F*)hTEtaNMixRawPt->Clone();
565     sprintf(name,"hTEtaNMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
566     hTEtaNMixCorrPt->SetName(name);
567     hTEtaNMixCorrPt->Divide(hTEtaNMixEffPt);
568
569     hTEtaACorrPt=(TH1F*)hTEtaARawPt->Clone();
570     sprintf(name,"hTEtaACorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
571     hTEtaACorrPt->SetName(name);
572     hTEtaACorrPt->Divide(hTEtaNEffPt);
573     
574     hTEtaAMixCorrPt=(TH1F*)hTEtaAMixRawPt->Clone();
575     sprintf(name,"hTEtaAMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
576     hTEtaAMixCorrPt->SetName(name);
577     hTEtaAMixCorrPt->Divide(hTEtaAMixEffPt);
578     
579     hTPhiEtaCorrPt=(TH2F*)hTPhiEtaRawPt->Clone();
580     sprintf(name,"hTPhiEtaCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
581     hTPhiEtaCorrPt->SetName(name);
582     hTPhiEtaCorrPt->Divide(hTPhiEtaEffPt);
583     
584     hTPhiEtaMixCorrPt=(TH2F*)hTPhiEtaMixRawPt->Clone();
585     sprintf(name,"hTPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
586     hTPhiEtaMixCorrPt->SetName(name);
587     hTPhiEtaMixCorrPt->Divide(hTPhiEtaMixEffPt);
588     //  cout << "hTPhiCorr " << hTPhiCorr->GetBinContent(1) << endl;
589     //GeoCorr(hTEtaNCorr,hTEtaNMixCorr,hTEtaNMixMC,hTEtaACorr,hTEtaAMixCorr,hTEtaAMixMC,hTPhiEtaCorr,hTPhiEtaMixCorr,hTPhiEtaMixMC);
590     //GeoCorr(hTEtaNCorrPt,hTEtaNMixCorrPt,hTEtaNMixMCPt,hTEtaACorrPt,hTEtaAMixCorrPt,hTEtaAMixMCPt,hTPhiEtaCorrPt,hTPhiEtaMixCorrPt,hTPhiEtaMixMCPt);
591     MixedCorrect(hTPhiCorr,hTPhiMixCorr,hTEtaNCorr,hTEtaNMixCorr,hTEtaACorr,hTEtaAMixCorr,hTPhiEtaCorr,hTPhiEtaMixCorr);
592   MixedCorrect(hTPhiCorrPt,hTPhiMixCorrPt,hTEtaNCorrPt,hTEtaNMixCorrPt,hTEtaACorrPt,hTEtaAMixCorrPt,hTPhiEtaCorrPt,hTPhiEtaMixCorrPt);
593     // cout << "hTPhiCorr " << hTPhiCorr->GetBinContent(1) << endl;
594   if(ZYAMCent>0)ZYA1(hTPhiCorr,hTPhiMixCorr,a,ZYAMCent,ZYAMWidth);
595   else ZYAM2D(hPhiEtaCorr,hPhiEtaMixCorr,a,72,10);
596     cout << "Normalization Factor: " << a[0] << endl;
597     hTPhiCorr2=(TH1F*)hTPhiCorr->Clone();
598     hTPhiCorr2->SetName("hTPhiCorr2");
599     sprintf(name,"Bg Sub. %s",hTPhiCorr2->GetTitle());
600     hTPhiCorr2->SetTitle(name);
601     
602     hTPhiMixCorr2=(TH1F*)hTPhiMixCorr->Clone();
603     hTPhiMixCorr2->SetName("hTPhiMixCorr2");
604     sprintf(name,"Normalized %1.3f %s",a[0],hTPhiMixCorr2->GetTitle());
605     hTPhiMixCorr2->SetTitle(name);
606     hTPhiMixCorr2->SetMarkerStyle(25);
607     hTPhiMixCorr2->SetMarkerColor(4);
608     hTPhiMixCorr2->SetLineColor(4);
609     
610     hTPhiEtaCorr2=(TH2F*)hTPhiEtaCorr->Clone();
611     hTPhiEtaCorr2->SetName("hTPhiEtaCorr2");
612     sprintf(name,"BG Sub. %s",hTPhiEtaCorr2->GetTitle());
613     hTPhiEtaCorr2->SetTitle(name);
614     
615     hTPhiEtaMixCorr2=(TH2F*)hTPhiEtaMixCorr->Clone();
616     hTPhiEtaMixCorr2->SetName("hTPhiEtaMixCorr2");
617     sprintf(name,"Normalized %1.3f %s",a[0],hTPhiEtaMixCorr2->GetTitle());
618     hTPhiEtaMixCorr2->SetTitle(name);
619     
620     hTPhiCorrPt2=(TH1F*)hTPhiCorrPt->Clone();
621     hTPhiCorrPt2->SetName("hTPhiCorrPt2");
622     sprintf(name,"Bg Sub. %s",hTPhiCorrPt2->GetTitle());
623     hTPhiCorrPt2->SetTitle(name);
624     
625     hTPhiMixCorrPt2=(TH1F*)hTPhiMixCorrPt->Clone();
626     hTPhiMixCorrPt2->SetName("hTPhiMixCorrPt2");
627     sprintf(name,"Normalized %1.3f %s",a[0],hTPhiMixCorrPt2->GetTitle());
628     hTPhiMixCorrPt2->SetTitle(name);
629     hTPhiMixCorrPt2->SetMarkerStyle(25);
630     hTPhiMixCorrPt2->SetMarkerColor(4);
631     hTPhiMixCorrPt2->SetLineColor(4);
632     
633     hTPhiEtaCorrPt2=(TH2F*)hTPhiEtaCorrPt->Clone();
634     hTPhiEtaCorrPt2->SetName("hTPhiEtaCorrPt2");
635     sprintf(name,"BG Sub. %s",hTPhiEtaCorrPt2->GetTitle());
636     hTPhiEtaCorrPt2->SetTitle(name);
637     
638     hTPhiEtaMixCorrPt2=(TH2F*)hTPhiEtaMixCorrPt->Clone();
639     hTPhiEtaMixCorrPt2->SetName("hTPhiEtaMixCorrPt2");
640     sprintf(name,"Normalized %1.3f %s",a[0],hTPhiEtaMixCorrPt2->GetTitle());
641     hTPhiEtaMixCorrPt2->SetTitle(name);
642     hTPhiMixCorr2->Scale(a[0]);
643     hTPhiEtaMixCorr2->Scale(a[0]);
644     hTPhiCorr2->Add(hTPhiMixCorr2,-1);
645     Add2D(hTPhiEtaCorr2,hTPhiEtaMixCorr2,-1);   
646     hTPhiMixCorrPt2->Scale(a[0]);
647     hTPhiEtaMixCorrPt2->Scale(a[0]);
648     hTPhiCorrPt2->Add(hTPhiMixCorrPt2,-1);
649     Add2D(hTPhiEtaCorrPt2,hTPhiEtaMixCorrPt2,-1); 
650     if(Cent==Mult1){
651       hTPhiCorrSum=(TH1F*)hTPhiCorr->Clone();
652       hTPhiCorrSum->SetName("hTPhiCorrSum");
653       hTPhiCorr2Sum=(TH1F*)hTPhiCorr2->Clone();
654       hTPhiCorr2Sum->SetName("hTPhiCorr2Sum");
655       hTPhiMixCorrSum=(TH1F*)hTPhiMixCorr->Clone();
656       hTPhiMixCorrSum->SetName("hTPhiMixCorrSum");
657       hTPhiMixCorr2Sum=(TH1F*)hTPhiMixCorr2->Clone();
658       hTPhiMixCorr2Sum->SetName("hTPhiMixCorr2Sum");
659       hTPhiEtaCorrSum=(TH2F*)hTPhiEtaCorr->Clone();
660       hTPhiEtaCorrSum->SetName("hTPhiEtaCorrSum");
661       hTPhiEtaCorr2Sum=(TH2F*)hTPhiEtaCorr2->Clone();
662       hTPhiEtaCorr2Sum->SetName("hTPhiEtaCorr2Sum");
663       hTPhiEtaMixCorrSum=(TH2F*)hTPhiEtaMixCorr->Clone();
664       hTPhiEtaMixCorrSum->SetName("hTPhiEtaMixCorrSum");
665       hTPhiEtaMixCorr2Sum=(TH2F*)hTPhiEtaMixCorr2->Clone();
666       hTPhiEtaMixCorr2Sum->SetName("hTPhiEtaMixCorr2Sum");      
667       
668       hTPhiCorrPtSum=(TH1F*)hTPhiCorrPt->Clone();
669       hTPhiCorrPtSum->SetName("hTPhiCorrPtSum");
670       hTPhiCorrPt2Sum=(TH1F*)hTPhiCorrPt2->Clone();
671       hTPhiCorrPt2Sum->SetName("hTPhiCorrPt2Sum");
672       hTPhiMixCorrPtSum=(TH1F*)hTPhiMixCorrPt->Clone();
673       hTPhiMixCorrPtSum->SetName("hTPhiMixCorrPtSum");
674       hTPhiMixCorrPt2Sum=(TH1F*)hTPhiMixCorrPt2->Clone();
675       hTPhiMixCorrPt2Sum->SetName("hTPhiMixCorrPt2Sum");
676       hTPhiEtaCorrPtSum=(TH2F*)hTPhiEtaCorrPt->Clone();
677       hTPhiEtaCorrPtSum->SetName("hTPhiEtaCorrPtSum");
678       hTPhiEtaCorrPt2Sum=(TH2F*)hTPhiEtaCorrPt2->Clone();
679       hTPhiEtaCorrPt2Sum->SetName("hTPhiEtaCorrPt2Sum");
680       hTPhiEtaMixCorrPtSum=(TH2F*)hTPhiEtaMixCorrPt->Clone();
681       hTPhiEtaMixCorrPtSum->SetName("hTPhiEtaMixCorrPtSum");
682       hTPhiEtaMixCorrPt2Sum=(TH2F*)hTPhiEtaMixCorrPt2->Clone();
683       hTPhiEtaMixCorrPt2Sum->SetName("hTPhiEtaMixCorrPt2Sum");
684       TrigSum=MPt[2];
685       hTPhiCorrSum->Scale(TrigSum);
686       hTPhiCorr2Sum->Scale(TrigSum);
687       hTPhiMixCorrSum->Scale(TrigSum);
688       hTPhiMixCorr2Sum->Scale(TrigSum);
689       hTPhiEtaCorrSum->Scale(TrigSum);
690       hTPhiEtaCorr2Sum->Scale(TrigSum);
691       hTPhiEtaMixCorrSum->Scale(TrigSum);
692       hTPhiEtaMixCorr2Sum->Scale(TrigSum);
693       
694       hTPhiCorrPtSum->Scale(TrigSum);
695       hTPhiCorrPt2Sum->Scale(TrigSum);
696       hTPhiMixCorrPtSum->Scale(TrigSum);
697       hTPhiMixCorrPt2Sum->Scale(TrigSum);
698       hTPhiEtaCorrPtSum->Scale(TrigSum);
699       hTPhiEtaCorrPt2Sum->Scale(TrigSum);
700       hTPhiEtaMixCorrPtSum->Scale(TrigSum);
701       hTPhiEtaMixCorrPt2Sum->Scale(TrigSum);
702     }
703     else{     
704       hTPhiCorrSum->Add(hTPhiCorr,MPt[2]);
705       hTPhiCorr2Sum->Add(hTPhiCorr2,MPt[2]);
706       hTPhiMixCorrSum->Add(hTPhiMixCorr,MPt[2]);
707       hTPhiMixCorr2Sum->Add(hTPhiMixCorr2,MPt[2]);
708       hTPhiEtaCorrSum->Add(hTPhiEtaCorr,MPt[2]);
709       hTPhiEtaCorr2Sum->Add(hTPhiEtaCorr2,MPt[2]);
710       hTPhiEtaMixCorrSum->Add(hTPhiEtaMixCorr,MPt[2]);
711       hTPhiEtaMixCorr2Sum->Add(hTPhiEtaMixCorr2,MPt[2]);
712       
713       hTPhiCorrPtSum->Add(hTPhiCorr,MPt[2]);
714       hTPhiCorrPt2Sum->Add(hTPhiCorr2,MPt[2]);
715       hTPhiMixCorrPtSum->Add(hTPhiMixCorr,MPt[2]);
716       hTPhiMixCorrPt2Sum->Add(hTPhiMixCorr2,MPt[2]);
717       hTPhiEtaCorrPtSum->Add(hTPhiEtaCorr,MPt[2]);
718       hTPhiEtaCorrPt2Sum->Add(hTPhiEtaCorr2,MPt[2]);
719       hTPhiEtaMixCorrPtSum->Add(hTPhiEtaMixCorr,MPt[2]);
720       hTPhiEtaMixCorrPt2Sum->Add(hTPhiEtaMixCorr2,MPt[2]);
721       TrigSum+=MPt[2];
722     }
723   }
724   cout << "TrigSum Inclusives: " << TrigSum << endl;
725   //rescale to per trigger
726   hTPhiCorrSum->Scale(1./TrigSum);
727   hTPhiCorr2Sum->Scale(1./TrigSum);
728   hTPhiMixCorrSum->Scale(1./TrigSum);
729   hTPhiMixCorr2Sum->Scale(1./TrigSum);
730   hTPhiEtaCorrSum->Scale(1./TrigSum);
731   hTPhiEtaCorr2Sum->Scale(1./TrigSum);
732   hTPhiEtaMixCorrSum->Scale(1./TrigSum);
733   hTPhiEtaMixCorr2Sum->Scale(1./TrigSum);
734   hTPhiCorrPtSum->Scale(1./TrigSum);
735   hTPhiCorrPt2Sum->Scale(1./TrigSum);
736   hTPhiMixCorrPtSum->Scale(1./TrigSum);
737   hTPhiMixCorrPt2Sum->Scale(1./TrigSum);
738   hTPhiEtaCorrPtSum->Scale(1./TrigSum);
739   hTPhiEtaCorrPt2Sum->Scale(1./TrigSum);
740   hTPhiEtaMixCorrPtSum->Scale(1./TrigSum);
741   hTPhiEtaMixCorrPt2Sum->Scale(1./TrigSum);
742
743   for(int MainLoop=0;MainLoop<nMainLoop;MainLoop++){
744   cout << "nMainLoop " << MainLoop << endl;
745     if(APtTPtMult==0){
746       APt1=APtBins[MainLoop];
747       APt2=APtBins[MainLoop+1];
748       MainArray[MainLoop]=(APt1+APt2)/2;
749       eMainArray[MainLoop]=(APt2-APt1)/2;
750       //cout << "APt1: " << APt1 << " APt2: " << APt2 << endl;
751     }
752     if(APtTPtMult==1){
753       TPt1=TPtBins[MainLoop];
754       TPt2=TPtBins[MainLoop+1];
755       MainArray[MainLoop]=(TPt1+TPt2)/2;
756       eMainArray[MainLoop]=(TPt2-TPt1)/2;
757       //cout << "TPt1: " << TPt1 << " TPt2: " << TPt2 << endl;
758     }
759     if(APtTPtMult==2){
760       Mult1=MultBins1[MainLoop];
761       Mult2=MultBins2[MainLoop];
762       MainArray[MainLoop]=(MultArray1[Mult1]+MultArray2[Mult2]-1)/2;
763       eMainArray[MainLoop]=(MultArray2[Mult2]-MultArray1[Mult1]-1)/2;           
764     }
765     for(int Cent=Mult1;Cent<=Mult2;Cent++){
766
767       MakeProjections(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiRaw,hPhiMixRaw,hEtaNRaw,hEtaNMixRaw,hEtaARaw,hEtaAMixRaw,hPhiEtaRaw,hPhiEtaMixRaw,MPt,0,0,0,LSign);
768       MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,MPt2,0,0,0,LSign);
769       MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiMC,hPhiMixMC,hEtaNMC,hEtaNMixMC,hEtaAMC,hEtaAMixMC,hPhiEtaMC,hPhiEtaMixMC,MPt2,0,1,0,LSign);
770       
771       MakeProjections(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiRawPt,hPhiMixRawPt,hEtaNRawPt,hEtaNMixRawPt,hEtaARawPt,hEtaAMixRawPt,hPhiEtaRawPt,hPhiEtaMixRawPt,MPt,1,0,0,LSign);
772       MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiEffPt,hPhiMixEffPt,hEtaNEffPt,hEtaNMixEffPt,hEtaAEffPt,hEtaAMixEffPt,hPhiEtaEffPt,hPhiEtaMixEffPt,MPt2,1,0,0,LSign);
773       MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiMCPt,hPhiMixMCPt,hEtaNMCPt,hEtaNMixMCPt,hEtaAMCPt,hEtaAMixMCPt,hPhiEtaMCPt,hPhiEtaMixMCPt,MPt2,1,1,0,LSign);
774       /*
775       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);
776       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);
777       */
778        if(EffMethod<4){
779       EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiEff,hPhiMC,hPhiMixEff,hPhiMixMC,hEtaNEff,hEtaNMC,hEtaNMixEff,hEtaNMixMC,hEtaAEff,hEtaAMC,hEtaAMixEff,hEtaAMixMC,hPhiEtaEff,hPhiEtaMC,hPhiEtaMixEff,hPhiEtaMixMC,EffMethod);
780    EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiEffPt,hPhiMCPt,hPhiMixEffPt,hPhiMixMCPt,hEtaNEffPt,hEtaNMCPt,hEtaNMixEffPt,hEtaNMixMCPt,hEtaAEffPt,hEtaAMCPt,hEtaAMixEffPt,hEtaAMixMCPt,hPhiEtaEffPt,hPhiEtaMCPt,hPhiEtaMixEffPt,hPhiEtaMixMCPt,EffMethod);
781     }
782     else{
783       EffFit(APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,LSign,VariablePtLimit);
784 EffFit(APt1,APt2,Cent,effList,hPhiEffPt,hPhiMixEffPt,hEtaNEffPT,hEtaNMixEffPt,hEtaAEffPt,hEtaAMixEffPt,hPhiEtaEffPt,hPhiEtaMixEffPt,LSign,VariablePtLimit);
785     }
786
787       hPhiCorr=(TH1F*)hPhiRaw->Clone();
788       sprintf(name,"hPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
789       hPhiCorr->SetName(name);
790       hPhiCorr->Divide(hPhiEff);
791     
792       hPhiMixCorr=(TH1F*)hPhiMixRaw->Clone();
793       sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
794       hPhiMixCorr->SetName(name);
795       hPhiMixCorr->Divide(hPhiMixEff);
796
797       hEtaNCorr=(TH1F*)hEtaNRaw->Clone();
798       sprintf(name,"hEtaNCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
799       hEtaNCorr->SetName(name);
800       hEtaNCorr->Divide(hEtaNEff);
801     
802       hEtaNMixCorr=(TH1F*)hEtaNMixRaw->Clone();
803       sprintf(name,"hEtaNMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
804       hEtaNMixCorr->SetName(name);
805       hEtaNMixCorr->Divide(hEtaNMixEff);
806
807       hEtaACorr=(TH1F*)hEtaARaw->Clone();
808       sprintf(name,"hEtaACorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
809       hEtaACorr->SetName(name);
810       hEtaACorr->Divide(hEtaAEff);
811     
812       hEtaAMixCorr=(TH1F*)hEtaAMixRaw->Clone();
813       sprintf(name,"hEtaAMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
814       hEtaAMixCorr->SetName(name);
815       hEtaAMixCorr->Divide(hEtaAMixEff);
816       
817       hPhiEtaCorr=(TH2F*)hPhiEtaRaw->Clone();
818       sprintf(name,"hPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
819       hPhiEtaCorr->SetName(name);
820       hPhiEtaCorr->Divide(hPhiEtaEff);
821       
822       hPhiEtaMixCorr=(TH2F*)hPhiEtaMixRaw->Clone();
823       sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
824       hPhiEtaMixCorr->SetName(name);
825       hPhiEtaMixCorr->Divide(hPhiEtaMixEff);
826       
827       hPhiCorrPt=(TH1F*)hPhiRawPt->Clone();
828       sprintf(name,"hPhiCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
829       hPhiCorrPt->SetName(name);
830       hPhiCorrPt->Divide(hPhiEffPt);
831       
832       hPhiMixCorrPt=(TH1F*)hPhiMixRawPt->Clone();
833       sprintf(name,"hPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
834       hPhiMixCorrPt->SetName(name);
835       hPhiMixCorrPt->Divide(hPhiMixEffPt);
836
837       hEtaNCorrPt=(TH1F*)hEtaNRawPt->Clone();
838       sprintf(name,"hEtaNCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
839       hEtaNCorrPt->SetName(name);
840       hEtaNCorrPt->Divide(hEtaNEffPt);
841       
842       hEtaNMixCorrPt=(TH1F*)hEtaNMixRawPt->Clone();
843       sprintf(name,"hEtaNMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
844       hEtaNMixCorrPt->SetName(name);
845       hEtaNMixCorrPt->Divide(hEtaNMixEffPt);
846
847       hEtaACorrPt=(TH1F*)hEtaARawPt->Clone();
848       sprintf(name,"hEtaACorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
849       hEtaACorrPt->SetName(name);
850       hEtaACorrPt->Divide(hEtaAEffPt);
851       
852       hEtaAMixCorrPt=(TH1F*)hEtaAMixRawPt->Clone();
853       sprintf(name,"hEtaAMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
854       hEtaAMixCorrPt->SetName(name);
855       hEtaAMixCorrPt->Divide(hEtaAMixEffPt);
856       
857       hPhiEtaCorrPt=(TH2F*)hPhiEtaRawPt->Clone();
858       sprintf(name,"hPhiEtaCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
859       hPhiEtaCorrPt->SetName(name);
860       hPhiEtaCorrPt->Divide(hPhiEtaEffPt);
861       
862       hPhiEtaMixCorrPt=(TH2F*)hPhiEtaMixRawPt->Clone();
863       sprintf(name,"hPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
864       hPhiEtaMixCorrPt->SetName(name);
865       hPhiEtaMixCorrPt->Divide(hPhiEtaMixEffPt);
866    
867       //   GeoCorr(hEtaNCorr,hEtaNMixCorr,hEtaNMixMC,hEtaACorr,hEtaAMixCorr,hEtaAMixMC,hPhiEtaCorr,hPhiEtaMixCorr,hPhiEtaMixMC);
868       // GeoCorr(hEtaNCorrPt,hEtaNMixCorrPt,hEtaNMixMCPt,hEtaACorrPt,hEtaAMixCorrPt,hEtaAMixMCPt,hPhiEtaCorrPt,hPhiEtaMixCorrPt,hPhiEtaMixMCPt);
869       MixedCorrect(hPhiCorr,hPhiMixCorr,hEtaNCorr,hEtaNMixCorr,hEtaACorr,hEtaAMixCorr,hPhiEtaCorr,hPhiEtaMixCorr);
870       MixedCorrect(hPhiCorrPt,hPhiMixCorrPt,hEtaNCorrPt,hEtaNMixCorrPt,hEtaACorrPt,hEtaAMixCorrPt,hPhiEtaCorrPt,hPhiEtaMixCorrPt);
871       if(ZYAMCent>0)ZYA1(hPhiCorr,hPhiMixCorr,a,ZYAMCent,ZYAMWidth);
872       else ZYAM2D(hPhiEtaCorr,hPhiEtaMixCorr,a,72,10);
873    
874
875       hPhiCorr2=(TH1F*)hPhiCorr->Clone();
876       hPhiCorr2->SetName("hPhiCorr2");
877       sprintf(name,"Bg Sub. %s",hPhiCorr2->GetTitle());
878       hPhiCorr2->SetTitle(name);
879       
880       hPhiMixCorr2=(TH1F*)hPhiMixCorr->Clone();
881       hPhiMixCorr2->SetName("hPhiMixCorr2");
882       sprintf(name,"Normalized %1.3f %s",a[0],hPhiMixCorr2->GetTitle());
883       hPhiMixCorr2->SetTitle(name);
884       hPhiMixCorr2->SetMarkerStyle(25);
885       hPhiMixCorr2->SetMarkerColor(4);
886       hPhiMixCorr2->SetLineColor(4);
887
888       hEtaNCorr2=(TH1F*)hEtaNCorr->Clone();
889       hEtaNCorr2->SetName("hEtaNCorr2");
890       sprintf(name,"Bg Sub. %s",hEtaNCorr2->GetTitle());
891       hEtaNCorr2->SetTitle(name);
892       
893       hEtaNMixCorr2=(TH1F*)hEtaNMixCorr->Clone();
894       hEtaNMixCorr2->SetName("hEtaNMixCorr2");
895       sprintf(name,"Normalized %1.3f %s",a[0],hEtaNMixCorr2->GetTitle());
896       hEtaNMixCorr2->SetTitle(name);
897       hEtaNMixCorr2->SetMarkerStyle(25);
898       hEtaNMixCorr2->SetMarkerColor(4);
899       hEtaNMixCorr2->SetLineColor(4);
900
901       hEtaACorr2=(TH1F*)hEtaACorr->Clone();
902       hEtaACorr2->SetName("hEtaACorr2");
903       sprintf(name,"Bg Sub. %s",hEtaACorr2->GetTitle());
904       hEtaACorr2->SetTitle(name);
905       
906       hEtaAMixCorr2=(TH1F*)hEtaAMixCorr->Clone();
907       hEtaAMixCorr2->SetName("hEtaAMixCorr2");
908       sprintf(name,"Normalized %1.3f %s",a[0],hEtaAMixCorr2->GetTitle());
909       hEtaAMixCorr2->SetTitle(name);
910       hEtaAMixCorr2->SetMarkerStyle(25);
911       hEtaAMixCorr2->SetMarkerColor(4);
912       hEtaAMixCorr2->SetLineColor(4);
913       
914       hPhiEtaCorr2=(TH2F*)hPhiEtaCorr->Clone();
915       hPhiEtaCorr2->SetName("hPhiEtaCorr2");
916       sprintf(name,"BG Sub. %s",hPhiEtaCorr2->GetTitle());
917       hPhiEtaCorr2->SetTitle(name);
918       
919       hPhiEtaMixCorr2=(TH2F*)hPhiEtaMixCorr->Clone();
920       hPhiEtaMixCorr2->SetName("hPhiEtaMixCorr2");
921       sprintf(name,"Normalized %1.3f %s",a[0],hPhiEtaMixCorr2->GetTitle());
922       hPhiEtaMixCorr2->SetTitle(name);
923       
924       hPhiCorrPt2=(TH1F*)hPhiCorrPt->Clone();
925       hPhiCorrPt2->SetName("hPhiCorrPt2");
926       sprintf(name,"Bg Sub. %s",hPhiCorrPt2->GetTitle());
927       hPhiCorrPt2->SetTitle(name);
928       
929       hPhiMixCorrPt2=(TH1F*)hPhiMixCorrPt->Clone();
930       hPhiMixCorrPt2->SetName("hPhiMixCorrPt2");
931       sprintf(name,"Normalized %1.3f %s",a[0],hPhiMixCorrPt2->GetTitle());
932       hPhiMixCorrPt2->SetTitle(name);
933       hPhiMixCorrPt2->SetMarkerStyle(25);
934       hPhiMixCorrPt2->SetMarkerColor(4);
935       hPhiMixCorrPt2->SetLineColor(4);
936
937       hEtaNCorrPt2=(TH1F*)hEtaNCorrPt->Clone();
938       hEtaNCorrPt2->SetName("hEtaNCorrPt2");
939       sprintf(name,"Bg Sub. %s",hEtaNCorrPt2->GetTitle());
940       hEtaNCorrPt2->SetTitle(name);
941       
942       hEtaNMixCorrPt2=(TH1F*)hEtaNMixCorrPt->Clone();
943       hEtaNMixCorrPt2->SetName("hEtaNMixCorrPt2");
944       sprintf(name,"Normalized %1.3f %s",a[0],hEtaNMixCorrPt2->GetTitle());
945       hEtaNMixCorrPt2->SetTitle(name);
946       hEtaNMixCorrPt2->SetMarkerStyle(25);
947       hEtaNMixCorrPt2->SetMarkerColor(4);
948       hEtaNMixCorrPt2->SetLineColor(4);
949
950       hEtaACorrPt2=(TH1F*)hEtaACorrPt->Clone();
951       hEtaACorrPt2->SetName("hEtaACorrPt2");
952       sprintf(name,"Bg Sub. %s",hEtaACorrPt2->GetTitle());
953       hEtaACorrPt2->SetTitle(name);
954       
955       hEtaAMixCorrPt2=(TH1F*)hEtaAMixCorrPt->Clone();
956       hEtaAMixCorrPt2->SetName("hEtaAMixCorrPt2");
957       sprintf(name,"Normalized %1.3f %s",a[0],hEtaAMixCorrPt2->GetTitle());
958       hEtaAMixCorrPt2->SetTitle(name);
959       hEtaAMixCorrPt2->SetMarkerStyle(25);
960       hEtaAMixCorrPt2->SetMarkerColor(4);
961       hEtaAMixCorrPt2->SetLineColor(4);
962       
963       hPhiEtaCorrPt2=(TH2F*)hPhiEtaCorrPt->Clone();
964       hPhiEtaCorrPt2->SetName("hPhiEtaCorrPt2");
965       sprintf(name,"BG Sub. %s",hPhiEtaCorrPt2->GetTitle());
966       hPhiEtaCorrPt2->SetTitle(name);
967       
968       hPhiEtaMixCorrPt2=(TH2F*)hPhiEtaMixCorrPt->Clone();
969       hPhiEtaMixCorrPt2->SetName("hPhiEtaMixCorrPt2");
970       sprintf(name,"Normalized %1.3f %s",a[0],hPhiEtaMixCorrPt2->GetTitle());
971       hPhiEtaMixCorrPt2->SetTitle(name);
972       
973       hPhiMixCorr2->Scale(a[0]);
974       hEtaNMixCorr2->Scale(a[0]);
975       hEtaAMixCorr2->Scale(a[0]);
976       hPhiEtaMixCorr2->Scale(a[0]);
977       hPhiCorr2->Add(hPhiMixCorr2,-1);
978       hEtaNCorr2->Add(hEtaNMixCorr2,-1);
979       hEtaACorr2->Add(hEtaAMixCorr2,-1);
980       Add2D(hPhiEtaCorr2,hPhiEtaMixCorr2,-1);   
981       hPhiMixCorrPt2->Scale(a[0]);
982       hPhiEtaMixCorrPt2->Scale(a[0]);
983       hEtaNMixCorrPt2->Scale(a[0]);
984       hEtaAMixCorrPt2->Scale(a[0]);
985       hPhiCorrPt2->Add(hPhiMixCorrPt2,-1);
986       hEtaNCorrPt2->Add(hEtaNMixCorrPt2,-1);
987       hEtaACorrPt2->Add(hEtaAMixCorrPt2,-1);
988       Add2D(hPhiEtaCorrPt2,hPhiEtaMixCorrPt2,-1);       
989       
990       //Now we need to add up centrality bins
991       if(Cent==Mult1){
992         hPhiCorrSum=(TH1F*)hPhiCorr->Clone();
993         hPhiCorrSum->SetName("hPhiCorrSum");
994         hPhiCorr2Sum=(TH1F*)hPhiCorr2->Clone();
995         hPhiCorr2Sum->SetName("hPhiCorr2Sum");
996         hPhiMixCorrSum=(TH1F*)hPhiMixCorr->Clone();
997         hPhiMixCorrSum->SetName("hPhiMixCorrSum");
998         hPhiMixCorr2Sum=(TH1F*)hPhiMixCorr2->Clone();
999         hPhiMixCorr2Sum->SetName("hPhiMixCorr2Sum");
1000         
1001         hEtaNCorrSum=(TH1F*)hEtaNCorr->Clone();
1002         hEtaNCorrSum->SetName("hEtaNCorrSum");
1003         hEtaNCorr2Sum=(TH1F*)hEtaNCorr2->Clone();
1004         hEtaNCorr2Sum->SetName("hEtaNCorr2Sum");
1005         hEtaNMixCorrSum=(TH1F*)hEtaNMixCorr->Clone();
1006         hEtaNMixCorrSum->SetName("hEtaNMixCorrSum");
1007         hEtaNMixCorr2Sum=(TH1F*)hEtaNMixCorr2->Clone();
1008         hEtaNMixCorr2Sum->SetName("hEtaNMixCorr2Sum");
1009         
1010         hEtaACorrSum=(TH1F*)hEtaACorr->Clone();
1011         hEtaACorrSum->SetName("hEtaACorrSum");
1012         hEtaACorr2Sum=(TH1F*)hEtaACorr2->Clone();
1013         hEtaACorr2Sum->SetName("hEtaACorr2Sum");
1014         hEtaAMixCorrSum=(TH1F*)hEtaAMixCorr->Clone();
1015         hEtaAMixCorrSum->SetName("hEtaAMixCorrSum");
1016         hEtaAMixCorr2Sum=(TH1F*)hEtaAMixCorr2->Clone();
1017         hEtaAMixCorr2Sum->SetName("hEtaAMixCorr2Sum");
1018
1019         hPhiEtaCorrSum=(TH2F*)hPhiEtaCorr->Clone();
1020         hPhiEtaCorrSum->SetName("hPhiEtaCorrSum");
1021         hPhiEtaCorr2Sum=(TH2F*)hPhiEtaCorr2->Clone();
1022         hPhiEtaCorr2Sum->SetName("hPhiEtaCorr2Sum");
1023         hPhiEtaMixCorrSum=(TH2F*)hPhiEtaMixCorr->Clone();
1024         hPhiEtaMixCorrSum->SetName("hPhiEtaMixCorrSum");
1025         hPhiEtaMixCorr2Sum=(TH2F*)hPhiEtaMixCorr2->Clone();
1026         hPhiEtaMixCorr2Sum->SetName("hPhiEtaMixCorr2Sum");      
1027         
1028         hPhiCorrPtSum=(TH1F*)hPhiCorrPt->Clone();
1029         hPhiCorrPtSum->SetName("hPhiCorrPtSum");
1030         hPhiCorrPt2Sum=(TH1F*)hPhiCorrPt2->Clone();
1031         hPhiCorrPt2Sum->SetName("hPhiCorrPt2Sum");
1032         hPhiMixCorrPtSum=(TH1F*)hPhiMixCorrPt->Clone();
1033         hPhiMixCorrPtSum->SetName("hPhiMixCorrPtSum");
1034         hPhiMixCorrPt2Sum=(TH1F*)hPhiMixCorrPt2->Clone();
1035         hPhiMixCorrPt2Sum->SetName("hPhiMixCorrPt2Sum");
1036
1037         hEtaNCorrPtSum=(TH1F*)hEtaNCorrPt->Clone();
1038         hEtaNCorrPtSum->SetName("hEtaNCorrPtSum");
1039         hEtaNCorrPt2Sum=(TH1F*)hEtaNCorrPt2->Clone();
1040         hEtaNCorrPt2Sum->SetName("hEtaNCorrPt2Sum");
1041         hEtaNMixCorrPtSum=(TH1F*)hEtaNMixCorrPt->Clone();
1042         hEtaNMixCorrPtSum->SetName("hEtaNMixCorrPtSum");
1043         hEtaNMixCorrPt2Sum=(TH1F*)hEtaNMixCorrPt2->Clone();
1044         hEtaNMixCorrPt2Sum->SetName("hEtaNMixCorrPt2Sum");
1045
1046         hEtaACorrPtSum=(TH1F*)hEtaACorrPt->Clone();
1047         hEtaACorrPtSum->SetName("hEtaACorrPtSum");
1048         hEtaACorrPt2Sum=(TH1F*)hEtaACorrPt2->Clone();
1049         hEtaACorrPt2Sum->SetName("hEtaACorrPt2Sum");
1050         hEtaAMixCorrPtSum=(TH1F*)hEtaAMixCorrPt->Clone();
1051         hEtaAMixCorrPtSum->SetName("hEtaAMixCorrPtSum");
1052         hEtaAMixCorrPt2Sum=(TH1F*)hEtaAMixCorrPt2->Clone();
1053         hEtaAMixCorrPt2Sum->SetName("hEtaAMixCorrPt2Sum");
1054
1055         hPhiEtaCorrPtSum=(TH2F*)hPhiEtaCorrPt->Clone();
1056         hPhiEtaCorrPtSum->SetName("hPhiEtaCorrPtSum");
1057         hPhiEtaCorrPt2Sum=(TH2F*)hPhiEtaCorrPt2->Clone();
1058         hPhiEtaCorrPt2Sum->SetName("hPhiEtaCorrPt2Sum");
1059         hPhiEtaMixCorrPtSum=(TH2F*)hPhiEtaMixCorrPt->Clone();
1060         hPhiEtaMixCorrPtSum->SetName("hPhiEtaMixCorrPtSum");
1061         hPhiEtaMixCorrPt2Sum=(TH2F*)hPhiEtaMixCorrPt2->Clone();
1062         hPhiEtaMixCorrPt2Sum->SetName("hPhiEtaMixCorrPt2Sum");  
1063         
1064         TrigSum=MPt[2];
1065         
1066         hPhiCorrSum->Scale(TrigSum);
1067         hPhiCorr2Sum->Scale(TrigSum);
1068         hPhiMixCorrSum->Scale(TrigSum);
1069         hPhiMixCorr2Sum->Scale(TrigSum);
1070         hEtaNCorrSum->Scale(TrigSum);
1071         hEtaNCorr2Sum->Scale(TrigSum);
1072         hEtaNMixCorrSum->Scale(TrigSum);
1073         hEtaNMixCorr2Sum->Scale(TrigSum);
1074         hEtaACorrSum->Scale(TrigSum);
1075         hEtaACorr2Sum->Scale(TrigSum);
1076         hEtaAMixCorrSum->Scale(TrigSum);
1077         hEtaAMixCorr2Sum->Scale(TrigSum);
1078         hPhiEtaCorrSum->Scale(TrigSum);
1079         hPhiEtaCorr2Sum->Scale(TrigSum);
1080         hPhiEtaMixCorrSum->Scale(TrigSum);
1081         hPhiEtaMixCorr2Sum->Scale(TrigSum);
1082         
1083         hPhiCorrPtSum->Scale(TrigSum);
1084         hPhiCorrPt2Sum->Scale(TrigSum);
1085         hPhiMixCorrPtSum->Scale(TrigSum);
1086         hPhiMixCorrPt2Sum->Scale(TrigSum);
1087         hEtaNCorrPtSum->Scale(TrigSum);
1088         hEtaNCorrPt2Sum->Scale(TrigSum);
1089         hEtaNMixCorrPtSum->Scale(TrigSum);
1090         hEtaNMixCorrPt2Sum->Scale(TrigSum);
1091         hEtaACorrPtSum->Scale(TrigSum);
1092         hEtaACorrPt2Sum->Scale(TrigSum);
1093         hEtaAMixCorrSum->Scale(TrigSum);
1094         hEtaAMixCorr2Sum->Scale(TrigSum);
1095         hPhiEtaCorrPtSum->Scale(TrigSum);
1096         hPhiEtaCorrPt2Sum->Scale(TrigSum);
1097         hPhiEtaMixCorrPtSum->Scale(TrigSum);
1098         hPhiEtaMixCorrPt2Sum->Scale(TrigSum);
1099       }
1100       else{//I need to do trigger weighted averaging here so I need the trigger counts
1101         hPhiCorrSum->Add(hPhiCorr,MPt[2]);
1102         hPhiCorr2Sum->Add(hPhiCorr2,MPt[2]);
1103         hPhiMixCorrSum->Add(hPhiMixCorr,MPt[2]);
1104         hPhiMixCorr2Sum->Add(hPhiMixCorr2,MPt[2]);
1105         hEtaNCorrSum->Add(hEtaNCorr,MPt[2]);
1106         hEtaNCorr2Sum->Add(hEtaNCorr2,MPt[2]);
1107         hEtaNMixCorrSum->Add(hEtaNMixCorr,MPt[2]);
1108         hEtaNMixCorr2Sum->Add(hEtaNMixCorr2,MPt[2]);
1109         hEtaACorrSum->Add(hEtaACorr,MPt[2]);
1110         hEtaACorr2Sum->Add(hEtaNCorr2,MPt[2]);
1111         hEtaAMixCorrSum->Add(hEtaAMixCorr,MPt[2]);
1112         hEtaAMixCorr2Sum->Add(hEtaAMixCorr2,MPt[2]);
1113         hPhiEtaCorrSum->Add(hPhiEtaCorr,MPt[2]);
1114         hPhiEtaCorr2Sum->Add(hPhiEtaCorr2,MPt[2]);
1115         hPhiEtaMixCorrSum->Add(hPhiEtaMixCorr,MPt[2]);
1116         hPhiEtaMixCorr2Sum->Add(hPhiEtaMixCorr2,MPt[2]);
1117         
1118         hPhiCorrPtSum->Add(hPhiCorr,MPt[2]);
1119         hPhiCorrPt2Sum->Add(hPhiCorr2,MPt[2]);
1120         hPhiMixCorrPtSum->Add(hPhiMixCorr,MPt[2]);
1121         hPhiMixCorrPt2Sum->Add(hPhiMixCorr2,MPt[2]);
1122         hEtaNCorrPtSum->Add(hEtaNCorrPt,MPt[2]);
1123         hEtaNCorrPt2Sum->Add(hEtaNCorrPt2,MPt[2]);
1124         hEtaNMixCorrPtSum->Add(hEtaNMixCorrPt,MPt[2]);
1125         hEtaNMixCorrPt2Sum->Add(hEtaNMixCorrPt2,MPt[2]);
1126         hEtaACorrPtSum->Add(hEtaACorrPt,MPt[2]);
1127         hEtaACorrPt2Sum->Add(hEtaNCorrPt2,MPt[2]);
1128         hEtaAMixCorrPtSum->Add(hEtaAMixCorrPt,MPt[2]);
1129         hEtaAMixCorrPt2Sum->Add(hEtaAMixCorrPt2,MPt[2]);
1130         hPhiEtaCorrPtSum->Add(hPhiEtaCorr,MPt[2]);
1131         hPhiEtaCorrPt2Sum->Add(hPhiEtaCorr2,MPt[2]);
1132         hPhiEtaMixCorrPtSum->Add(hPhiEtaMixCorr,MPt[2]);
1133         hPhiEtaMixCorrPt2Sum->Add(hPhiEtaMixCorr2,MPt[2]);
1134         TrigSum+=MPt[2];
1135       }
1136     }
1137     //rescale to per trigger
1138     // cout << "TrigSum " << TrigSum << endl;
1139     hPhiCorrSum->Scale(1./TrigSum);
1140     hPhiCorr2Sum->Scale(1./TrigSum);
1141     hPhiMixCorrSum->Scale(1./TrigSum);
1142     hPhiMixCorr2Sum->Scale(1./TrigSum);
1143     hEtaNCorrSum->Scale(1./TrigSum);
1144     hEtaNCorr2Sum->Scale(1./TrigSum);
1145     hEtaNMixCorrSum->Scale(1./TrigSum);
1146     hEtaNMixCorr2Sum->Scale(1./TrigSum);
1147     hEtaACorrSum->Scale(1./TrigSum);
1148     hEtaACorr2Sum->Scale(1./TrigSum);
1149     hEtaAMixCorrSum->Scale(1./TrigSum);
1150     hEtaAMixCorr2Sum->Scale(1./TrigSum);
1151     hPhiEtaCorrSum->Scale(1./TrigSum);
1152     hPhiEtaCorr2Sum->Scale(1./TrigSum);
1153     hPhiEtaMixCorrSum->Scale(1./TrigSum);
1154     hPhiEtaMixCorr2Sum->Scale(1./TrigSum);
1155     
1156     hPhiCorrPtSum->Scale(1./TrigSum);
1157     hPhiCorrPt2Sum->Scale(1./TrigSum);
1158     hPhiMixCorrPtSum->Scale(1./TrigSum);
1159     hPhiMixCorrPt2Sum->Scale(1./TrigSum);
1160     hEtaNCorrPtSum->Scale(1./TrigSum);
1161     hEtaNCorrPt2Sum->Scale(1./TrigSum);
1162     hEtaNMixCorrPtSum->Scale(1./TrigSum);
1163     hEtaNMixCorrPt2Sum->Scale(1./TrigSum);
1164     hEtaACorrPtSum->Scale(1./TrigSum);
1165     hEtaACorrPt2Sum->Scale(1./TrigSum);
1166     hEtaAMixCorrPtSum->Scale(1./TrigSum);
1167     hEtaAMixCorrPt2Sum->Scale(1./TrigSum);
1168     hPhiEtaCorrPtSum->Scale(1./TrigSum);
1169     hPhiEtaCorrPt2Sum->Scale(1./TrigSum);
1170     hPhiEtaMixCorrPtSum->Scale(1./TrigSum);
1171     hPhiEtaMixCorrPt2Sum->Scale(1./TrigSum);
1172     
1173     //  for(int xs=0;xs<nx;xs++){xarray[xs][MainLoop]=0;}
1174     for(int yields=0;yields<nyields;yields++){  
1175       NYieldPhi[yields][MainLoop]=0;
1176       NYieldPhiZYAM[yields][MainLoop]=0;
1177       NYieldPhiFit[yields][MainLoop]=0;
1178       NYieldEta[yields][MainLoop]=0;
1179       NYieldEtaZYAM[yields][MainLoop]=0;
1180       NYieldEtaFit[yields][MainLoop]=0;
1181       NYieldPhiEta1[yields][MainLoop]=0;
1182       NYieldPhiEta2[yields][MainLoop]=0;
1183       NYieldPhiEta1ZYAM[yields][MainLoop]=0;
1184       NYieldPhiEta2ZYAM[yields][MainLoop]=0;
1185       NRMSPhi[yields][MainLoop]=0;
1186       NWidthPhi[yields][MainLoop]=0;
1187       AYieldPhi[yields][MainLoop]=0;
1188       AYieldPhiZYAM[yields][MainLoop]=0;
1189       AYieldPhiFit[yields][MainLoop]=0;
1190       AYieldEta[yields][MainLoop]=0;
1191       AYieldEtaZYAM[yields][MainLoop]=0;
1192       AYieldEtaFit[yields][MainLoop]=0;
1193       AYieldPhiEta[yields][MainLoop]=0;
1194       AYieldPhiEtaZYAM[yields][MainLoop]=0;
1195       MYieldPhi[yields][MainLoop]=0;
1196       MYieldPhi[yields][MainLoop]=0;
1197       MAvePhiEta[yields][MainLoop]=0;
1198       NAvePhi[yields][MainLoop]=0;
1199       NAvePhiZYAM[yields][MainLoop]=0;
1200       NAvePhiFit[yields][MainLoop]=0;
1201       NAveEta[yields][MainLoop]=0;
1202       NAveEtaZYAM[yields][MainLoop]=0;
1203       NAveEtaFit[yields][MainLoop]=0;
1204       NAvePhiEta1[yields][MainLoop]=0;
1205       NAvePhiEta2[yields][MainLoop]=0;
1206       NAvePhiEta1ZYAM[yields][MainLoop]=0;
1207       NAvePhiEta2ZYAM[yields][MainLoop]=0;
1208       AAvePhi[yields][MainLoop]=0;
1209       AAvePhiZYAM[yields][MainLoop]=0;
1210       AAvePhiFit[yields][MainLoop]=0;
1211       AAveEta[yields][MainLoop]=0;
1212       AAveEtaZYAM[yields][MainLoop]=0;
1213       AAveEtaFit[yields][MainLoop]=0;
1214       AAvePhiEta[yields][MainLoop]=0;
1215       AAvePhiEtaZYAM[yields][MainLoop]=0;
1216       MAvePhi[yields][MainLoop]=0;
1217       MAvePhiFit[yields][MainLoop]=0;
1218       MAvePhiEta[yields][MainLoop]=0;
1219       
1220       TNYieldPhi[yields][MainLoop]=0;
1221       TNYieldPhiZYAM[yields][MainLoop]=0;
1222       TNYieldPhiFit[yields][MainLoop]=0;
1223       TNYieldPhiEta1[yields][MainLoop]=0;
1224       TNYieldPhiEta2[yields][MainLoop]=0;
1225       TNYieldPhiEta3[yields][MainLoop]=0;
1226       TAYieldPhi[yields][MainLoop]=0;
1227       TAYieldPhiZYAM[yields][MainLoop]=0;
1228       TAYieldPhiFit[yields][MainLoop]=0;
1229       TAYieldPhiEta[yields][MainLoop]=0;
1230       TAYieldPhiEtaZYAM[yields][MainLoop]=0;
1231     }
1232     //lets do the dphi histo yeilds
1233     //Get our yields for the $\Delta\phi$ Histograms (from bin counting)
1234     float nbinsPhiEtaPhi=hPhiEtaCorr->GetNbinsX();
1235     float nbinsPhiEtaEta=hPhiEtaCorr->GetNbinsY();
1236     binwx=hPhiCorr->GetBinWidth(1);
1237     NearBinsPhi=0;
1238     AwayBinsPhi=0;
1239     MinBinsPhi=0;
1240     NearBinsPhiEta1=0;
1241     NearBinsPhiEta2=0;
1242     AwayBinsPhiEta=0;
1243     MinBinsPhiEta=0;
1244     
1245     //Bins with 0 content have messed up error bars and screw up the fits
1246     for(int xx=1;xx<=hPhiCorrSum->GetNbinsX();xx++){
1247       if(hPhiCorrSum->GetBinContent(xx)==0)hPhiCorrSum->SetBinError(xx,1./hPhiCorrSum->GetBinWidth(xx)/TrigSum);
1248       if(hPhiCorrPtSum->GetBinContent(xx)==0)hPhiCorrSum->SetBinError(xx,1./pow(hPhiCorrPtSum->GetBinWidth(xx),2)/TrigSum);
1249     }
1250  for(int xx=1;xx<=hEtaNCorrSum->GetNbinsX();xx++){
1251    if(hEtaNCorrSum->GetBinContent(xx)==0){
1252      float acp=1-fabs(hEtaNCorr->GetBinCenter(xx))/1.8;
1253      hEtaNCorrSum->SetBinError(xx,1./hEtaNCorrSum->GetBinWidth(xx)/TrigSum/acp);
1254      // cout << "Error Eta" << hEtaNCorrSum->GetBinContent(xx) << " " << hEtaNCorrSum->GetBinError(xx) << endl;
1255    }
1256    if(hEtaNCorrPtSum->GetBinContent(xx)==0)hEtaNCorrPtSum->SetBinError(xx,1./hEtaNCorrPtSum->GetBinWidth(xx)/TrigSum/acp);
1257     }
1258     
1259     //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
1260     trms1=0;trms2=0;trms3=0;
1261     char outName[200];
1262     cfit1=new TCanvas("cfit1","",800,600);
1263     //Fit The Histograms
1264     fit1->SetParameters(1,0.2,1,0.4,0.5);
1265     hPhiCorrSum->Fit("fit1");
1266     NYieldPhiFit[0][MainLoop]=fit1->GetParameter(0);
1267     NYieldPhiFit[1][MainLoop]=fit1->GetParError(0);
1268     NWidthPhi[0][MainLoop]=fit1->GetParameter(1);
1269     NWidthPhi[1][MainLoop]=fit1->GetParError(1);
1270     AYieldPhiFit[0][MainLoop]=fit1->GetParameter(2);
1271     AYieldPhiFit[1][MainLoop]=fit1->GetParError(2);
1272     AWidthPhi[0][MainLoop]=fit1->GetParameter(3);
1273     AWidthPhi[1][MainLoop]=fit1->GetParError(3);
1274     MYieldPhiFit[0][MainLoop]=fit1->GetParameter(4)*2*Pi;
1275     MYieldPhiFit[1][MainLoop]=fit1->GetParError(4)*2*Pi;
1276     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);
1277     if(SaveFits)cfit1->SaveAs(outName);
1278
1279     cfit2=new TCanvas("cfit2","",800,600);
1280     //float par4=fit1->GetParameter(4)*1.5*4/(hEtaNCorrSum->GetNbinsX()*hEtaNCorrSum->GetBinWidth(1));//proper scaling (selfcorrects for different bin etc)
1281     //  float par4=fit1->GetParameter(4)*hPhiCorrSum->GetBinWidth(1)/hEtaNCorrSum->GetBinWidth(1)*0.8/3.14159;
1282     //float par4=fit1->GetParameter(4)*3/3.2;
1283  float par4=fit1->GetParameter(4)*6.4/3;
1284     fit2->SetParameter(2,par4);
1285     // fit2->SetParLimits(2,par4,par4);
1286     fit2->SetParameter(0,fit1->GetParameter(0));
1287     fit2->SetParameter(1,fit1->GetParameter(1));
1288     hEtaNCorrSum->Fit("fit2");
1289     NYieldEtaFit[0][MainLoop]=fit2->GetParameter(0);
1290     NYieldEtaFit[1][MainLoop]=fit2->GetParError(0);
1291     NWidthEta[0][MainLoop]=fit2->GetParameter(1);
1292     NWidthEta[1][MainLoop]=fit2->GetParError(1);
1293     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);
1294     if(SaveFits)cfit2->SaveAs(outName);
1295
1296     hPhiCorrPtSum->Fit("fit1");
1297     NYieldPhiFit[2][MainLoop]=fit1->GetParameter(0);
1298     NYieldPhiFit[3][MainLoop]=fit1->GetParError(0);
1299     NWidthPhi[2][MainLoop]=fit1->GetParameter(1);
1300     NWidthPhi[3][MainLoop]=fit1->GetParError(1);
1301     AYieldPhiFit[2][MainLoop]=fit1->GetParameter(2);
1302     AYieldPhiFit[3][MainLoop]=fit1->GetParError(2);
1303     AWidthPhi[2][MainLoop]=fit1->GetParameter(3);
1304     AWidthPhi[3][MainLoop]=fit1->GetParError(3);
1305     MYieldPhiFit[2][MainLoop]=fit1->GetParameter(4)*2*Pi;
1306     MYieldPhiFit[3][MainLoop]=fit1->GetParError(4)*2*Pi;
1307
1308   
1309     // par4=fit1->GetParameter(4)*hPhiCorrSum->GetBinWidth(1)/hEtaNCorrSum->GetBinWidth(1)*1.5/3.1415962;
1310     //float par4=fit1->GetParameter(4)*1.5*2/1.8;
1311     //float par4=fit1->GetParameter(4)*1.5*4/(hEtaNCorrPtSum->GetNbinsX()*hEtaNCorrPtSum->GetBinWidth(1));
1312     //float par4=fit1->GetParameter(4)*hPhiCorrSum->GetBinWidth(1)/hEtaNCorrSum->GetBinWidth(1)*1.5/3.14159;
1313     float par4=fit1->GetParameter(4)*6.4/3;
1314     fit2->SetParameter(2,par4);
1315     //fit2->SetParLimits(2,par4,par4);
1316     fit2->SetParameter(0,fit1->GetParameter(0));
1317     fit2->SetParameter(1,fit1->GetParameter(1));
1318     //hEtaNCorrSum->Fit("fit2");
1319     // fit2->SetParLimits(2,fit1->GetParameter(4),fit1->GetParameter(4));
1320     hEtaNCorrPtSum->Fit("fit2");
1321     NYieldEtaFit[2][MainLoop]=fit2->GetParameter(0);
1322     NYieldEtaFit[3][MainLoop]=fit2->GetParError(0);
1323     NWidthEta[2][MainLoop]=fit2->GetParameter(1);
1324     NWidthEta[3][MainLoop]=fit2->GetParError(1);
1325
1326     //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
1327     AYieldEtaFit[0][MainLoop]=1;
1328     AYieldEtaFit[1][MainLoop]=1;
1329     AWidthEta[0][MainLoop]=1;
1330     AWidthEta[1][MainLoop]=1;
1331     AYieldEtaFit[2][MainLoop]=1;
1332     AYieldEtaFit[3][MainLoop]=1;
1333     AWidthEta[2][MainLoop]=1;
1334     AWidthEta[3][MainLoop]=1;
1335
1336     //Average pT from fits
1337     NAvePhiFit[0][MainLoop]=NYieldPhiFit[2][MainLoop]/NYieldPhiFit[0][MainLoop];
1338     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);
1339     AAvePhiFit[0][MainLoop]=AYieldPhiFit[2][MainLoop]/AYieldPhiFit[0][MainLoop];
1340     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);
1341     MAvePhiFit[0][MainLoop]=MYieldPhiFit[2][MainLoop]/MYieldPhiFit[0][MainLoop];
1342     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);
1343     NAveEtaFit[0][MainLoop]=NYieldEtaFit[2][MainLoop]/NYieldEtaFit[0][MainLoop];
1344     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);
1345
1346     //Computer Jt from the fits
1347     float meanptA=NYieldPhiFit[2][MainLoop]/NYieldPhiFit[0][MainLoop];
1348     float EmeanptA=meanptA*sqrt(pow(NYieldPhiFit[3][MainLoop]/NYieldPhiFit[2][MainLoop],2)+pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2));
1349     NJtPhi[0][MainLoop]=NWidthPhi[0][MainLoop]*meanptA*MPt[0]*pow(2/(meanptA*meanptA+MPt[0]*MPt[0]),0.5);
1350     float temp1=pow(MPt[0]*MPt[0]+meanptA*meanptA,0.5);
1351     float temp2=2*EmeanptA*meanptA+2*MPt[0]*MPt[1];
1352     float temp3=0.5*temp2/temp1;
1353     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);
1354
1355     meanptA=NYieldEtaFit[2][MainLoop]/NYieldEtaFit[0][MainLoop];
1356     EmeanptA=meanptA*sqrt(pow(NYieldEtaFit[3][MainLoop]/NYieldEtaFit[2][MainLoop],2)+pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2));
1357     NJtEta[0][MainLoop]=NWidthEta[0][MainLoop]*meanptA*MPt[0]*pow(2/(meanptA*meanptA+MPt[0]*MPt[0]),0.5);
1358     temp1=pow(MPt[0]*MPt[0]+meanptA*meanptA,0.5);
1359     temp2=2*EmeanptA*meanptA+2*MPt[0]*MPt[1];
1360     temp3=0.5*temp2/temp1;
1361     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);
1362
1363     //PhiLoop
1364     for(int x1=0;x1<hPhiCorrSum->GetNbinsX();x1++){
1365       centx=hPhiCorrSum->GetBinCenter(x1);
1366       //Near-Side 1d
1367       if(fabs(centx)<NearWidthPhi||fabs(centx-2*Pi)<NearWidthPhi||fabs(centx+2*Pi)<NearWidthPhi){
1368         NYieldPhi[0][MainLoop]+=binwx*hPhiCorrSum->GetBinContent(x1);
1369         NYieldPhi[1][MainLoop]+=pow(binwx*hPhiCorrSum->GetBinError(x1),2);
1370         NYieldPhi[2][MainLoop]+=binwx*hPhiCorrPtSum->GetBinContent(x1);
1371         NYieldPhi[3][MainLoop]+=pow(binwx*hPhiCorrPtSum->GetBinError(x1),2);
1372         NYieldPhiZYAM[0][MainLoop]+=binwx*hPhiCorr2Sum->GetBinContent(x1);
1373         NYieldPhiZYAM[1][MainLoop]+=pow(binwx*hPhiCorr2Sum->GetBinError(x1),2);
1374         NYieldPhiZYAM[2][MainLoop]+=binwx*hPhiCorrPt2Sum->GetBinContent(x1);
1375         NYieldPhiZYAM[3][MainLoop]+=pow(binwx*hPhiCorrPt2Sum->GetBinError(x1),2);
1376         if(APtTPtMult==0){
1377           TNYieldPhi[0][MainLoop]+=binwx*hTPhiCorrSum->GetBinContent(x1);
1378           TNYieldPhi[1][MainLoop]+=pow(binwx*hTPhiCorrSum->GetBinError(x1),2);
1379           TNYieldPhi[2][MainLoop]+=binwx*hTPhiCorrPtSum->GetBinContent(x1);
1380           TNYieldPhi[3][MainLoop]+=pow(binwx*hTPhiCorrPtSum->GetBinError(x1),2);
1381           TNYieldPhiZYAM[0][MainLoop]+=binwx*hTPhiCorr2Sum->GetBinContent(x1);
1382           TNYieldPhiZYAM[1][MainLoop]+=pow(binwx*hTPhiCorr2Sum->GetBinError(x1),2);
1383           TNYieldPhiZYAM[2][MainLoop]+=binwx*hTPhiCorrPt2Sum->GetBinContent(x1);
1384           TNYieldPhiZYAM[3][MainLoop]+=pow(binwx*hTPhiCorrPt2Sum->GetBinError(x1),2);
1385         }
1386         NRMSPhi[0][MainLoop]+=pow(binwx*centx*hPhiCorr2Sum->GetBinContent(x1),2);
1387         NRMSPhi[1][MainLoop]+=pow(2*binwx*centx*hPhiCorr2Sum->GetBinError(x1),2);
1388         NRMSPhi[2][MainLoop]+=pow(binwx*centx*hPhiCorrPt2Sum->GetBinContent(x1),2);
1389         NRMSPhi[3][MainLoop]+=pow(2*binwx*centx*hPhiCorrPt2Sum->GetBinError(x1),2);
1390         //how do I want to do the errors
1391         //1/RMS*(2*sum cont*centx/sum cont)(1/sum cont^2)*err
1392         //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
1393         NearBinsPhi++;
1394       }
1395       //AwaySide 1d
1396       if(fabs(centx-Pi)<AwayWidthPhi||fabs(centx-3*Pi)<AwayWidthPhi||fabs(centx+Pi)<AwayWidthPhi){
1397         trms1=(centx-Pi);
1398         if(trms1<Pi)trms1+=2*Pi;
1399         if(trms1>Pi)trms1-=2*Pi;
1400         AYieldPhi[0][MainLoop]+=binwx*hPhiCorrSum->GetBinContent(x1);
1401         AYieldPhi[1][MainLoop]+=pow(binwx*hPhiCorrSum->GetBinContent(x1),2);
1402         AYieldPhi[2][MainLoop]+=binwx*hPhiCorrPtSum->GetBinContent(x1);
1403         AYieldPhi[3][MainLoop]+=pow(binwx*hPhiCorrPtSum->GetBinError(x1),2);
1404         AYieldPhiZYAM[0][MainLoop]+=binwx*hPhiCorr2Sum->GetBinContent(x1);
1405         AYieldPhiZYAM[1][MainLoop]+=pow(binwx*hPhiCorr2Sum->GetBinError(x1),2);
1406         AYieldPhiZYAM[2][MainLoop]+=binwx*hPhiCorrPt2Sum->GetBinContent(x1);
1407         AYieldPhiZYAM[3][MainLoop]+=pow(binwx*hPhiCorrPt2Sum->GetBinError(x1),2);
1408         ARMSPhi[0][MainLoop]+=pow(binwx*trms1*hPhiCorr2Sum->GetBinContent(x1),2);
1409         ARMSPhi[1][MainLoop]+=pow(2*binwx*trms1*hPhiCorr2Sum->GetBinError(x1),2);
1410         ARMSPhi[2][MainLoop]+=pow(binwx*trms1*hPhiCorrPt2Sum->GetBinContent(x1),2);
1411         ARMSPhi[3][MainLoop]+=pow(2*binwx*trms1*hPhiCorrPt2Sum->GetBinError(x1),2);
1412         AwayBinsPhi++;
1413       }
1414       //Minimum
1415       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){
1416         MYieldPhi[0][MainLoop]+=hPhiCorrSum->GetBinContent(x1);
1417         MYieldPhi[1][MainLoop]+=pow(hPhiCorrSum->GetBinError(x1),2);
1418         MYieldPhi[2][MainLoop]+=hPhiCorrPtSum->GetBinContent(x1);
1419         MYieldPhi[3][MainLoop]+=pow(hPhiCorrPtSum->GetBinError(x1),2);
1420         MinBinsPhi++;
1421       }
1422     }//Phi Loop
1423
1424     //EtaLoop
1425     binwx=hEtaNCorrSum->GetBinWidth(1);
1426     for(int x1=1;x1<=hEtaNCorrSum->GetNbinsX();x1++){
1427       NYieldEta[0][MainLoop]+=binwx*hEtaNCorrSum->GetBinContent(x1);
1428       NYieldEta[1][MainLoop]+=pow(binwx*hEtaNCorrSum->GetBinError(x1),2);
1429       NYieldEta[2][MainLoop]+=binwx*hEtaNCorrPtSum->GetBinContent(x1);
1430       NYieldEta[3][MainLoop]+=pow(binwx*hEtaNCorrPtSum->GetBinError(x1),2);
1431       NYieldEtaZYAM[0][MainLoop]+=binwx*hEtaNCorr2Sum->GetBinContent(x1);
1432       NYieldEtaZYAM[1][MainLoop]+=pow(binwx*hEtaNCorr2Sum->GetBinError(x1),2);
1433       NYieldEtaZYAM[2][MainLoop]+=binwx*hEtaNCorrPt2Sum->GetBinContent(x1);
1434       NYieldEtaZYAM[3][MainLoop]+=pow(binwx*hEtaNCorrPt2Sum->GetBinError(x1),2);
1435       AYieldEta[0][MainLoop]+=binwx*hEtaACorrSum->GetBinContent(x1);
1436       AYieldEta[1][MainLoop]+=pow(binwx*hEtaACorrSum->GetBinError(x1),2);
1437       AYieldEta[2][MainLoop]+=binwx*hEtaACorrPtSum->GetBinContent(x1);
1438       AYieldEta[3][MainLoop]+=pow(binwx*hEtaACorrPtSum->GetBinError(x1),2);
1439       AYieldEtaZYAM[0][MainLoop]+=binwx*hEtaACorr2Sum->GetBinContent(x1);
1440       AYieldEtaZYAM[1][MainLoop]+=pow(binwx*hEtaACorr2Sum->GetBinError(x1),2);
1441       AYieldEtaZYAM[2][MainLoop]+=binwx*hEtaACorrPt2Sum->GetBinContent(x1);
1442       AYieldEtaZYAM[3][MainLoop]+=pow(binwx*hEtaACorrPt2Sum->GetBinError(x1),2);
1443     }//EtaLoop
1444       
1445
1446     phiaxis=hPhiEtaCorrSum->GetXaxis();
1447     etaaxis=hPhiEtaCorrSum->GetYaxis();
1448     binwx=phiaxis->GetBinWidth(1);
1449     binwy=etaaxis->GetBinWidth(1);
1450     for(int x1=0;x1<hPhiEtaCorrSum->GetNbinsX();x1++){
1451       centx=phiaxis->GetBinCenter(x1);
1452       for(int y1=0;y1<hPhiEtaCorrSum->GetNbinsY();y1++){
1453         centy=etaaxis->GetBinCenter(y1);
1454         //Near-Side 2 d
1455         if(fabs(centx)<NearWidthPhi||fabs(centx-2*Pi)<NearWidthPhi||fabs(centx+2*Pi)<NearWidthPhi){
1456           //Jet Peak Area
1457           if(fabs(centy)<NearWidthEta){
1458             NYieldPhiEta1[0][MainLoop]+=binwx*binwy*hPhiEtaCorrSum->GetBinContent(x1,y1);
1459             NYieldPhiEta1[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrSum->GetBinError(x1,y1),2);
1460             NYieldPhiEta1[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPtSum->GetBinContent(x1,y1);
1461             NYieldPhiEta1[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
1462             NYieldPhiEta1ZYAM[0][MainLoop]+=binwx*binwy*hPhiEtaCorr2Sum->GetBinContent(x1,y1);
1463             NYieldPhiEta1ZYAM[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorr2Sum->GetBinError(x1,y1),2);
1464             NYieldPhiEta1ZYAM[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPt2Sum->GetBinContent(x1,y1);
1465             NYieldPhiEta1ZYAM[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPt2Sum->GetBinError(x1,y1),2);
1466             NearBinsPhiEta1++;
1467           }
1468           //Ridge Area
1469           else{
1470             NYieldPhiEta2[0][MainLoop]+=binwx*binwy*hPhiEtaCorrSum->GetBinContent(x1,y1);
1471             NYieldPhiEta2[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrSum->GetBinError(x1,y1),2);
1472             NYieldPhiEta2[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPtSum->GetBinContent(x1,y1);
1473             NYieldPhiEta2[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
1474             NYieldPhiEta2ZYAM[0][MainLoop]+=binwx*binwy*hPhiEtaCorr2Sum->GetBinContent(x1,y1);
1475             NYieldPhiEta2ZYAM[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorr2Sum->GetBinError(x1,y1),2);
1476             NYieldPhiEta2ZYAM[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPt2Sum->GetBinContent(x1,y1);
1477             NYieldPhiEta2ZYAM[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPt2Sum->GetBinError(x1,y1),2);
1478             NearBinsPhiEta2++;
1479           }
1480         }
1481         //Away-side 2D
1482         if(fabs(centx-Pi)<AwayWidthPhi||fabs(centx-3*Pi)<AwayWidthPhi||fabs(centx+Pi)<AwayWidthPhi){
1483           AYieldPhiEta[0][MainLoop]+=binwx*binwy*hPhiEtaCorrSum->GetBinContent(x1,y1);
1484           AYieldPhiEta[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrSum->GetBinError(x1,y1),2);
1485           AYieldPhiEta[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPtSum->GetBinContent(x1,y1);
1486           AYieldPhiEta[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
1487           AYieldPhiEtaZYAM[0][MainLoop]+=binwx*binwy*hPhiEtaCorr2Sum->GetBinContent(x1,y1);
1488           AYieldPhiEtaZYAM[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorr2Sum->GetBinError(x1,y1),2);
1489           AYieldPhiEtaZYAM[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPt2Sum->GetBinContent(x1,y1);
1490           AYieldPhiEtaZYAM[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPt2Sum->GetBinError(x1,y1),2);
1491           AwayBinsPhiEta++;
1492         }
1493         //Minimum 2D
1494         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){
1495           MYieldPhiEta[0][MainLoop]+=hPhiEtaCorrSum->GetBinContent(x1,y1);
1496           MYieldPhiEta[1][MainLoop]+=pow(hPhiEtaCorrSum->GetBinError(x1,y1),2);
1497           MYieldPhiEta[2][MainLoop]+=hPhiEtaCorrPtSum->GetBinContent(x1,y1);
1498           MYieldPhiEta[3][MainLoop]+=pow(hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
1499           MinBinsPhiEta++;
1500         }//Min 2d
1501       }//y
1502     }//x
1503
1504     //Averages
1505     
1506     cout << NYieldPhiZYAM[0][MainLoop] << endl;
1507     cout << AYieldPhiZYAM[0][MainLoop] << endl;
1508     cout << MYieldPhi[0][MainLoop] << endl;
1509     cout << NYieldEtaZYAM[0][MainLoop] << endl;
1510     cout << AYieldEtaZYAM[0][MainLoop] << endl;
1511     
1512     NAvePhi[0][MainLoop]=NYieldPhiZYAM[2][MainLoop]/NYieldPhiZYAM[0][MainLoop];
1513     AAvePhi[0][MainLoop]=AYieldPhiZYAM[2][MainLoop]/AYieldPhiZYAM[0][MainLoop];
1514     if(MYieldPhi[0][MainLoop]) MAvePhi[0][MainLoop]=MYieldPhi[2][MainLoop]/MYieldPhi[0][MainLoop];
1515     else MAvePhi[0][MainLoop]=0;
1516     NAveEta[0][MainLoop]=NYieldEtaZYAM[2][MainLoop]/NYieldEtaZYAM[0][MainLoop];
1517     AAveEta[0][MainLoop]=AYieldEtaZYAM[2][MainLoop]/AYieldEtaZYAM[0][MainLoop];
1518     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);
1519     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);
1520     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);
1521     else (MAvePhi[1][MainLoop])=1;
1522     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);
1523     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);
1524
1525     //Set up the Error bars correctly
1526     NYieldPhi[1][MainLoop]=sqrt(NYieldPhi[1][MainLoop]);
1527     NYieldPhi[3][MainLoop]=sqrt(NYieldPhi[3][MainLoop]);
1528     AYieldPhi[1][MainLoop]=sqrt(AYieldPhi[1][MainLoop]);
1529     AYieldPhi[3][MainLoop]=sqrt(AYieldPhi[3][MainLoop]);
1530     NYieldPhiZYAM[1][MainLoop]=sqrt(NYieldPhiZYAM[1][MainLoop]);
1531     NYieldPhiZYAM[3][MainLoop]=sqrt(NYieldPhiZYAM[3][MainLoop]);
1532     AYieldPhiZYAM[1][MainLoop]=sqrt(AYieldPhiZYAM[1][MainLoop]);
1533     AYieldPhiZYAM[3][MainLoop]=sqrt(AYieldPhiZYAM[3][MainLoop]);
1534     MYieldPhi[1][MainLoop]=sqrt(MYieldPhi[1][MainLoop]);
1535     MYieldPhi[3][MainLoop]=sqrt(MYieldPhi[3][MainLoop]);
1536
1537     NYieldEta[1][MainLoop]=sqrt(NYieldEta[1][MainLoop]);
1538     NYieldEta[3][MainLoop]=sqrt(NYieldEta[3][MainLoop]);
1539     AYieldEta[1][MainLoop]=sqrt(AYieldEta[1][MainLoop]);
1540     AYieldEta[3][MainLoop]=sqrt(AYieldEta[3][MainLoop]);
1541     NYieldEtaZYAM[1][MainLoop]=sqrt(NYieldEtaZYAM[1][MainLoop]);
1542     NYieldEtaZYAM[3][MainLoop]=sqrt(NYieldEtaZYAM[3][MainLoop]);
1543     AYieldEtaZYAM[1][MainLoop]=sqrt(AYieldEtaZYAM[1][MainLoop]);
1544     AYieldEtaZYAM[3][MainLoop]=sqrt(AYieldEtaZYAM[3][MainLoop]);
1545     
1546     //Set Minimums to total number of charged particles
1547     MYieldPhi[0][MainLoop]=MYieldPhi[0][MainLoop]/MinBinsPhi*2*Pi;
1548     MYieldPhi[1][MainLoop]=MYieldPhi[1][MainLoop]/MinBinsPhi*2*Pi;
1549     MYieldPhi[2][MainLoop]=MYieldPhi[2][MainLoop]/MinBinsPhi*2*Pi;
1550     MYieldPhi[3][MainLoop]=MYieldPhi[3][MainLoop]/MinBinsPhi*2*Pi;
1551     MYieldPhiEta[0][MainLoop]=MYieldPhiEta[0][MainLoop]/MinBinsPhiEta*2*Pi;
1552     MYieldPhiEta[1][MainLoop]=MYieldPhiEta[1][MainLoop]/MinBinsPhiEta*2*Pi;
1553     MYieldPhiEta[2][MainLoop]=MYieldPhiEta[2][MainLoop]/MinBinsPhiEta*2*Pi;
1554     MYieldPhiEta[3][MainLoop]=MYieldPhiEta[3][MainLoop]/MinBinsPhiEta*2*Pi;
1555   
1556     //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)
1557     NXPhi[0][MainLoop]=MainArray[MainLoop];
1558     NXPhi[1][MainLoop]=eMainArray[MainLoop];
1559     AXPhi[0][MainLoop]=MainArray[MainLoop];
1560     AXPhi[1][MainLoop]=eMainArray[MainLoop];
1561     NXPhiFit[0][MainLoop]=MainArray[MainLoop];
1562     NXPhiFit[1][MainLoop]=eMainArray[MainLoop];
1563     AXPhiFit[0][MainLoop]=MainArray[MainLoop];
1564     AXPhiFit[1][MainLoop]=eMainArray[MainLoop];
1565
1566     NXEta[0][MainLoop]=MainArray[MainLoop];
1567     NXEta[1][MainLoop]=eMainArray[MainLoop];
1568     AXEta[0][MainLoop]=MainArray[MainLoop];
1569     AXEta[1][MainLoop]=eMainArray[MainLoop];
1570     NXEtaFit[0][MainLoop]=MainArray[MainLoop];
1571     NXEtaFit[1][MainLoop]=eMainArray[MainLoop];
1572     AXEtaFit[0][MainLoop]=MainArray[MainLoop];
1573     AXEtaFit[1][MainLoop]=eMainArray[MainLoop];
1574
1575     NXPhiEta1[0][MainLoop]=MainArray[MainLoop];
1576     NXPhiEta1[1][MainLoop]=eMainArray[MainLoop];
1577     NXPhiEta2[0][MainLoop]=MainArray[MainLoop];
1578     NXPhiEta2[1][MainLoop]=eMainArray[MainLoop];
1579     AXPhiEta[0][MainLoop]=MainArray[MainLoop];
1580     AXPhiEta[1][MainLoop]=eMainArray[MainLoop];
1581   
1582     if(APtTPtMult==0){//spectra so <pt_assoc>
1583       if(NYieldPhiZYAM[0][MainLoop]==0) NYieldPhiZYAM[0][MainLoop]=0.00000001;
1584       if(NYieldPhiZYAM[2][MainLoop]==0) NYieldPhiZYAM[2][MainLoop]=0.00000001;
1585       if(AYieldPhiZYAM[0][MainLoop]==0) AYieldPhiZYAM[0][MainLoop]=0.00000001;
1586       if(AYieldPhiZYAM[2][MainLoop]==0) AYieldPhiZYAM[2][MainLoop]=0.00000001;
1587       NXPhi[2][MainLoop]=NYieldPhiZYAM[2][MainLoop]/NYieldPhiZYAM[0][MainLoop];
1588       NXPhi[3][MainLoop]=NXPhi[2][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+pow(NYieldPhiZYAM[3][MainLoop]/NYieldPhiZYAM[2][MainLoop],2));
1589       AXPhi[2][MainLoop]=AYieldPhiZYAM[2][MainLoop]/AYieldPhiZYAM[0][MainLoop];
1590       AXPhi[3][MainLoop]=AXPhi[2][MainLoop]*sqrt(pow(AYieldPhiZYAM[1][MainLoop]/AYieldPhiZYAM[0][MainLoop],2)+pow(AYieldPhiZYAM[3][MainLoop]/AYieldPhiZYAM[2][MainLoop],2));
1591       NXPhiFit[2][MainLoop]=NYieldPhiFit[2][MainLoop]/NYieldPhiFit[0][MainLoop];
1592       // cout << "Pt " << NXPhiFit[2][MainLoop] << endl;
1593       NXPhiFit[3][MainLoop]=NXPhiFit[2][MainLoop]*sqrt(pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2)+pow(NYieldPhiFit[3][MainLoop]/NYieldPhiFit[2][MainLoop],2));
1594       AXPhiFit[2][MainLoop]=AYieldPhiFit[2][MainLoop]/AYieldPhiFit[0][MainLoop];
1595       AXPhiFit[3][MainLoop]=AXPhiFit[2][MainLoop]*sqrt(pow(AYieldPhiFit[1][MainLoop]/AYieldPhiFit[0][MainLoop],2)+pow(AYieldPhiFit[3][MainLoop]/AYieldPhiFit[2][MainLoop],2));
1596
1597       NXEta[2][MainLoop]=NYieldEtaZYAM[2][MainLoop]/NYieldEtaZYAM[0][MainLoop];
1598       NXEta[3][MainLoop]=NXEta[2][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+pow(NYieldEtaZYAM[3][MainLoop]/NYieldEtaZYAM[2][MainLoop],2));
1599       AXEta[2][MainLoop]=AYieldEtaZYAM[2][MainLoop]/AYieldEtaZYAM[0][MainLoop];
1600       AXEta[3][MainLoop]=AXEta[2][MainLoop]*sqrt(pow(AYieldEtaZYAM[1][MainLoop]/AYieldEtaZYAM[0][MainLoop],2)+pow(AYieldEtaZYAM[3][MainLoop]/AYieldEtaZYAM[2][MainLoop],2));
1601       NXEtaFit[2][MainLoop]=NYieldEtaFit[2][MainLoop]/NYieldEtaFit[0][MainLoop];
1602       NXEtaFit[3][MainLoop]=NXEtaFit[2][MainLoop]*sqrt(pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2)+pow(NYieldEtaFit[3][MainLoop]/NYieldEtaFit[2][MainLoop],2));
1603       AXEtaFit[2][MainLoop]=AYieldEtaFit[2][MainLoop]/AYieldEtaFit[0][MainLoop];
1604       AXEtaFit[3][MainLoop]=AXEtaFit[2][MainLoop]*sqrt(pow(AYieldEtaFit[1][MainLoop]/AYieldEtaFit[0][MainLoop],2)+pow(AYieldEtaFit[3][MainLoop]/AYieldEtaFit[2][MainLoop],2));
1605
1606       
1607       /*
1608         NXPhiEta1[2][MainLoop]=NYieldPhiEta1[2][MainLoop]/NYieldPhiEta1[0][MainLoop];
1609         NXPhiEta1[3][MainLoop]=NXPhiEta1[2][MainLoop][0]*sqrt(pow(NYieldPhiEta1[1][MainLoop]/NYieldPhiEta1[0][MainLoop],2)+pow(NYieldPhiEta1[3][MainLoop]/NYieldPhiEta1[2][MainLoop],2));
1610         NXPhiEta2[2][MainLoop]=NYieldPhiEta2[2][MainLoop]/NYieldPhiEta2[0][MainLoop];
1611         NXPhiEta2[3][MainLoop]=NXPhiEta2[2][MainLoop][0]*sqrt(pow(NYieldPhiEta2[1][MainLoop]/NYieldPhiEta2[0][MainLoop],2)+pow(NYieldPhiEta2[3][MainLoop]/NYieldPhiEta2[2][MainLoop],2));
1612         AXPhiEta[2][MainLoop]=AYieldPhiEta[2][MainLoop]/AYieldPhiEta[0][MainLoop];
1613         AXPhiEta[3][MainLoop]=AXPhiEta[2][MainLoop][0]*sqrt(pow(AYieldPhiEta[1][MainLoop]/AYieldPhiEta[0][MainLoop],2)+pow(AYieldPhiEta[3][MainLoop]/AYieldPhiEta[2][MainLoop],2));
1614       */
1615    
1616       if(NXPhi[1][MainLoop]<NXPhi[3][MainLoop]){
1617         NXPhi[4][MainLoop]=NXPhi[0][MainLoop];
1618         NXPhi[5][MainLoop]=NXPhi[1][MainLoop];
1619       }
1620       else{
1621         NXPhi[4][MainLoop]=NXPhi[2][MainLoop];
1622         NXPhi[5][MainLoop]=NXPhi[3][MainLoop];
1623       } 
1624       if(AXPhi[1][MainLoop]<AXPhi[3][MainLoop]){
1625         AXPhi[4][MainLoop]=AXPhi[0][MainLoop];
1626         AXPhi[5][MainLoop]=AXPhi[1][MainLoop];
1627       }
1628       else{
1629         AXPhi[4][MainLoop]=AXPhi[2][MainLoop];
1630         AXPhi[5][MainLoop]=AXPhi[3][MainLoop];
1631       } 
1632       if(NXPhiFit[1][MainLoop]<NXPhiFit[3][MainLoop]){
1633         NXPhiFit[4][MainLoop]=NXPhiFit[0][MainLoop];
1634         NXPhiFit[5][MainLoop]=NXPhiFit[1][MainLoop];
1635       }
1636       else{
1637         NXPhiFit[4][MainLoop]=NXPhiFit[2][MainLoop];
1638         NXPhiFit[5][MainLoop]=NXPhiFit[3][MainLoop];
1639       } 
1640       if(AXPhiFit[1][MainLoop]<AXPhiFit[3][MainLoop]){
1641         AXPhiFit[4][MainLoop]=AXPhiFit[0][MainLoop];
1642         AXPhiFit[5][MainLoop]=AXPhiFit[1][MainLoop];
1643       }
1644       else{
1645         AXPhiFit[4][MainLoop]=AXPhiFit[2][MainLoop];
1646         AXPhiFit[5][MainLoop]=AXPhiFit[3][MainLoop];
1647       } 
1648
1649       if(NXEta[1][MainLoop]<NXEta[3][MainLoop]){
1650         NXEta[4][MainLoop]=NXEta[0][MainLoop];
1651         NXEta[5][MainLoop]=NXEta[1][MainLoop];
1652       }
1653       else{
1654         NXEta[4][MainLoop]=NXEta[2][MainLoop];
1655         NXEta[5][MainLoop]=NXEta[3][MainLoop];
1656       } 
1657       if(AXEta[1][MainLoop]<AXEta[3][MainLoop]){
1658         AXEta[4][MainLoop]=AXEta[0][MainLoop];
1659         AXEta[5][MainLoop]=AXEta[1][MainLoop];
1660       }
1661       else{
1662         AXEta[4][MainLoop]=AXEta[2][MainLoop];
1663         AXEta[5][MainLoop]=AXEta[3][MainLoop];
1664       } 
1665       if(NXEtaFit[1][MainLoop]<NXEtaFit[3][MainLoop]){
1666         NXEtaFit[4][MainLoop]=NXEtaFit[0][MainLoop];
1667         NXEtaFit[5][MainLoop]=NXEtaFit[1][MainLoop];
1668       }
1669       else{
1670         NXEtaFit[4][MainLoop]=NXEtaFit[2][MainLoop];
1671         NXEtaFit[5][MainLoop]=NXEtaFit[3][MainLoop];
1672       } 
1673       if(AXEtaFit[1][MainLoop]<AXEtaFit[3][MainLoop]){
1674         AXEtaFit[4][MainLoop]=AXEtaFit[0][MainLoop];
1675         AXEtaFit[5][MainLoop]=AXEtaFit[1][MainLoop];
1676       }
1677       else{
1678         AXEtaFit[4][MainLoop]=AXEtaFit[2][MainLoop];
1679         AXEtaFit[5][MainLoop]=AXEtaFit[3][MainLoop];
1680       } 
1681       
1682       for(int tloop=0;tloop<=2; tloop++){
1683         NXPhi[6+2*tloop][MainLoop]=NXPhi[0+2*tloop][MainLoop]/MPt[0];
1684         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));
1685         NXPhi[12+2*tloop][MainLoop]=NXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
1686         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));
1687         AXPhi[6+2*tloop][MainLoop]=AXPhi[0+2*tloop][MainLoop]/MPt[0];
1688         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));
1689         AXPhi[12+2*tloop][MainLoop]=AXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
1690         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));
1691
1692         NXPhiFit[6+2*tloop][MainLoop]=NXPhiFit[0+2*tloop][MainLoop]/MPt[0];
1693         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));
1694         //      NXPhi[12+2*tloop][MainLoop]=NXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
1695         //      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));
1696         AXPhiFit[6+2*tloop][MainLoop]=AXPhiFit[0+2*tloop][MainLoop]/MPt[0];
1697         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));
1698         //      AXPhi[12+2*tloop][MainLoop]=AXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
1699         //      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));
1700
1701         NXEta[6+2*tloop][MainLoop]=NXEta[0+2*tloop][MainLoop]/MPt[0];
1702         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));
1703         //      NXEta[12+2*tloop][MainLoop]=NXEta[0+2*tloop][MainLoop]/(MPt[0]+TNYieldEtaZYAM[2][MainLoop]);
1704         //      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));
1705         AXEta[6+2*tloop][MainLoop]=AXEta[0+2*tloop][MainLoop]/MPt[0];
1706         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));
1707         //AXEta[12+2*tloop][MainLoop]=AXEta[0+2*tloop][MainLoop]/(MPt[0]+TNYieldEtaZYAM[2][MainLoop]);
1708         //      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));
1709
1710         NXEtaFit[6+2*tloop][MainLoop]=NXEtaFit[0+2*tloop][MainLoop]/MPt[0];
1711         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));
1712         AXEtaFit[6+2*tloop][MainLoop]=AXEtaFit[0+2*tloop][MainLoop]/MPt[0];
1713         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));
1714
1715       }
1716     
1717       NYieldPhi[4][MainLoop]=NYieldPhi[0][MainLoop]/NXPhi[1][MainLoop];
1718       NYieldPhi[5][MainLoop]=NYieldPhi[1][MainLoop]/NXPhi[1][MainLoop];
1719       NYieldPhi[6][MainLoop]=NYieldPhi[0][MainLoop]/NXPhi[1][MainLoop]*MPt[0];
1720       NYieldPhi[7][MainLoop]=NYieldPhi[6][MainLoop]*sqrt(pow(NYieldPhi[1][MainLoop]/NYieldPhi[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1721       NYieldPhi[8][MainLoop]=NYieldPhi[0][MainLoop]/NXPhi[1][MainLoop]*(MPt[0]+TNYieldPhi[2][MainLoop]);
1722       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));
1723       NYieldPhiFit[7][MainLoop]=NYieldPhiFit[6][MainLoop]*sqrt(pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1724       NYieldPhiZYAM[4][MainLoop]=NYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop];
1725       NYieldPhiZYAM[5][MainLoop]=NYieldPhiZYAM[1][MainLoop]/NXPhi[1][MainLoop];
1726       NYieldPhiZYAM[6][MainLoop]=NYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*MPt[0];
1727       NYieldPhiZYAM[7][MainLoop]=NYieldPhiZYAM[6][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1728       NYieldPhiZYAM[8][MainLoop]=NYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*(MPt[0]+TNYieldPhi[2][MainLoop]);
1729       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));
1730       AYieldPhiZYAM[4][MainLoop]=AYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop];
1731       AYieldPhiZYAM[5][MainLoop]=AYieldPhiZYAM[1][MainLoop]/NXPhi[1][MainLoop];
1732       AYieldPhiZYAM[6][MainLoop]=AYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*MPt[0];
1733       AYieldPhiZYAM[7][MainLoop]=AYieldPhiZYAM[6][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1734       AYieldPhiZYAM[8][MainLoop]=AYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*(MPt[0]+TNYieldPhi[2][MainLoop]);
1735       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));
1736       
1737       NYieldPhiFit[4][MainLoop]=NYieldPhiFit[0][MainLoop]/NXPhiFit[1][MainLoop];
1738       NYieldPhiFit[5][MainLoop]=NYieldPhiFit[1][MainLoop]/NXPhiFit[1][MainLoop];
1739       NYieldPhiFit[6][MainLoop]=NYieldPhiFit[0][MainLoop]/NXPhiFit[1][MainLoop]*MPt[0];
1740       AYieldPhiFit[4][MainLoop]=AYieldPhiFit[0][MainLoop]/AXPhiFit[1][MainLoop];
1741       AYieldPhiFit[5][MainLoop]=AYieldPhiFit[1][MainLoop]/AXPhiFit[1][MainLoop];
1742       AYieldPhiFit[6][MainLoop]=AYieldPhiFit[0][MainLoop]/AXPhiFit[1][MainLoop]*MPt[0];
1743       AYieldPhiFit[7][MainLoop]=AYieldPhiFit[6][MainLoop]*sqrt(pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1744
1745       NYieldEta[4][MainLoop]=NYieldEta[0][MainLoop]/NXEta[1][MainLoop];
1746       NYieldEta[5][MainLoop]=NYieldEta[1][MainLoop]/NXEta[1][MainLoop];
1747       NYieldEta[6][MainLoop]=NYieldEta[0][MainLoop]/NXEta[1][MainLoop]*MPt[0];
1748       NYieldEta[7][MainLoop]=NYieldEta[6][MainLoop]*sqrt(pow(NYieldEta[1][MainLoop]/NYieldEta[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1749       // NYieldEta[8][MainLoop]=NYieldEta[0][MainLoop]/NXEta[1][MainLoop]*(MPt[0]+TNYieldEta[2][MainLoop]);
1750       //  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));
1751       NYieldEtaFit[7][MainLoop]=NYieldEtaFit[6][MainLoop]*sqrt(pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1752       NYieldEtaZYAM[4][MainLoop]=NYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop];
1753       NYieldEtaZYAM[5][MainLoop]=NYieldEtaZYAM[1][MainLoop]/NXEta[1][MainLoop];
1754       NYieldEtaZYAM[6][MainLoop]=NYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*MPt[0];
1755       NYieldEtaZYAM[7][MainLoop]=NYieldEtaZYAM[6][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1756       // NYieldEtaZYAM[8][MainLoop]=NYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*(MPt[0]+TNYieldEta[2][MainLoop]);
1757       //  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));
1758       AYieldEtaZYAM[4][MainLoop]=AYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop];
1759       AYieldEtaZYAM[5][MainLoop]=AYieldEtaZYAM[1][MainLoop]/NXEta[1][MainLoop];
1760       AYieldEtaZYAM[6][MainLoop]=AYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*MPt[0];
1761       AYieldEtaZYAM[7][MainLoop]=AYieldEtaZYAM[6][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1762       //  AYieldEtaZYAM[8][MainLoop]=AYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*(MPt[0]+TNYieldEta[2][MainLoop]);
1763       //  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));
1764       
1765       NYieldEtaFit[4][MainLoop]=NYieldEtaFit[0][MainLoop]/NXEtaFit[1][MainLoop];
1766       NYieldEtaFit[5][MainLoop]=NYieldEtaFit[1][MainLoop]/NXEtaFit[1][MainLoop];
1767       NYieldEtaFit[6][MainLoop]=NYieldEtaFit[0][MainLoop]/NXEtaFit[1][MainLoop]*MPt[0];
1768       AYieldEtaFit[4][MainLoop]=AYieldEtaFit[0][MainLoop]/AXEtaFit[1][MainLoop];
1769       AYieldEtaFit[5][MainLoop]=AYieldEtaFit[1][MainLoop]/AXEtaFit[1][MainLoop];
1770       AYieldEtaFit[6][MainLoop]=AYieldEtaFit[0][MainLoop]/AXEtaFit[1][MainLoop]*MPt[0];
1771       AYieldEtaFit[7][MainLoop]=AYieldEtaFit[6][MainLoop]*sqrt(pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
1772     } 
1773   
1774     if(APtTPtMult==1){//Trigger pt dependence so <pt_Trig>
1775       NXPhi[2][MainLoop]=MPt[0];
1776       NXPhi[3][MainLoop]=MPt[1];
1777       AXPhi[2][MainLoop]=MPt[0];
1778       AXPhi[3][MainLoop]=MPt[1];
1779       NXPhiFit[2][MainLoop]=MPt[0];
1780       NXPhiFit[3][MainLoop]=MPt[1];
1781       AXPhiFit[2][MainLoop]=MPt[0];
1782       AXPhiFit[3][MainLoop]=MPt[1];
1783       
1784       NXEta[2][MainLoop]=MPt[0];
1785       NXEta[3][MainLoop]=MPt[1];
1786       AXEta[2][MainLoop]=MPt[0];
1787       AXEta[3][MainLoop]=MPt[1];
1788       NXEtaFit[2][MainLoop]=MPt[0];
1789       NXEtaFit[3][MainLoop]=MPt[1];
1790       AXEtaFit[2][MainLoop]=MPt[0];
1791       AXEtaFit[3][MainLoop]=MPt[1];
1792
1793       NXPhiEta1[2][MainLoop]=MPt[0];
1794       NXPhiEta1[3][MainLoop]=MPt[1];
1795       NXPhiEta2[2][MainLoop]=MPt[0];
1796       NXPhiEta2[3][MainLoop]=MPt[1];
1797       AXPhiEta[2][MainLoop]=MPt[0];
1798       AXPhiEta[3][MainLoop]=MPt[1];
1799
1800       if(NXPhi[1][MainLoop]<NXPhi[3][MainLoop]){
1801         NXPhi[4][MainLoop]=NXPhi[0][MainLoop];
1802         NXPhi[5][MainLoop]=NXPhi[1][MainLoop];
1803       }
1804       else{
1805         NXPhi[4][MainLoop]=NXPhi[2][MainLoop];
1806         NXPhi[5][MainLoop]=NXPhi[3][MainLoop];
1807       }
1808       if(AXPhi[1][MainLoop]<AXPhi[3][MainLoop]){
1809         AXPhi[4][MainLoop]=AXPhi[0][MainLoop];
1810         AXPhi[5][MainLoop]=AXPhi[1][MainLoop];
1811       }
1812       else{
1813         AXPhi[4][MainLoop]=AXPhi[2][MainLoop];
1814         AXPhi[5][MainLoop]=AXPhi[3][MainLoop];
1815       } 
1816       if(NXPhiFit[1][MainLoop]<NXPhiFit[3][MainLoop]){
1817         NXPhiFit[4][MainLoop]=NXPhiFit[0][MainLoop];
1818         NXPhiFit[5][MainLoop]=NXPhiFit[1][MainLoop];
1819       }
1820       else{
1821         NXPhiFit[4][MainLoop]=NXPhiFit[2][MainLoop];
1822         NXPhiFit[5][MainLoop]=NXPhiFit[3][MainLoop];
1823       }
1824       if(AXPhiFit[1][MainLoop]<AXPhiFit[3][MainLoop]){
1825         AXPhiFit[4][MainLoop]=AXPhiFit[0][MainLoop];
1826         AXPhiFit[5][MainLoop]=AXPhiFit[1][MainLoop];
1827       }
1828       else{
1829         AXPhiFit[4][MainLoop]=AXPhiFit[2][MainLoop];
1830         AXPhiFit[5][MainLoop]=AXPhiFit[3][MainLoop];
1831       } 
1832
1833       if(NXEta[1][MainLoop]<NXEta[3][MainLoop]){
1834         NXEta[4][MainLoop]=NXEta[0][MainLoop];
1835         NXEta[5][MainLoop]=NXEta[1][MainLoop];
1836       }
1837       else{
1838         NXEta[4][MainLoop]=NXEta[2][MainLoop];
1839         NXEta[5][MainLoop]=NXEta[3][MainLoop];
1840       }
1841       if(AXEta[1][MainLoop]<AXEta[3][MainLoop]){
1842         AXEta[4][MainLoop]=AXEta[0][MainLoop];
1843         AXEta[5][MainLoop]=AXEta[1][MainLoop];
1844       }
1845       else{
1846         AXEta[4][MainLoop]=AXEta[2][MainLoop];
1847         AXEta[5][MainLoop]=AXEta[3][MainLoop];
1848       } 
1849       if(NXEtaFit[1][MainLoop]<NXEtaFit[3][MainLoop]){
1850         NXEtaFit[4][MainLoop]=NXEtaFit[0][MainLoop];
1851         NXEtaFit[5][MainLoop]=NXEtaFit[1][MainLoop];
1852       }
1853       else{
1854         NXEtaFit[4][MainLoop]=NXEtaFit[2][MainLoop];
1855         NXEtaFit[5][MainLoop]=NXEtaFit[3][MainLoop];
1856       }
1857       if(AXEtaFit[1][MainLoop]<AXEtaFit[3][MainLoop]){
1858         AXEtaFit[4][MainLoop]=AXEtaFit[0][MainLoop];
1859         AXEtaFit[5][MainLoop]=AXEtaFit[1][MainLoop];
1860       }
1861       else{
1862         AXEtaFit[4][MainLoop]=AXEtaFit[2][MainLoop];
1863         AXEtaFit[5][MainLoop]=AXEtaFit[3][MainLoop];
1864       } 
1865
1866       
1867     }
1868     if(APtTPtMult==2){//Centrality so Mult
1869       NXPhi[2][MainLoop]=0;
1870       NXPhi[3][MainLoop]=0;
1871       tempsum=0;
1872       for(int multx=(MultArray1[Mult1]+1);multx<(MultArray2[Mult2]+1);multx++){
1873         NXPhi[2][MainLoop]+=hMult->GetBinCenter(multx)*(multx-1);
1874         NXPhi[3][MainLoop]+=pow(hMult->GetBinError(multx),2);
1875         tempsum+=hMult->GetBinCenter(multx);
1876       }
1877       NXPhi[2][MainLoop]/=tempsum;
1878       NXPhi[3][MainLoop]=sqrt(NXPhi[3][MainLoop])/tempsum;
1879       AXPhi[2][MainLoop]=NXPhi[2][MainLoop];
1880       AXPhi[3][MainLoop]=NXPhi[3][MainLoop];
1881       NXPhiFit[2][MainLoop]=NXPhi[2][MainLoop];
1882       NXPhiFit[3][MainLoop]=NXPhi[3][MainLoop];
1883       AXPhiFit[2][MainLoop]=AXPhi[2][MainLoop];
1884       AXPhiFit[3][MainLoop]=AXPhi[3][MainLoop];
1885       
1886       NXPhiEta1[2][MainLoop]=NXPhi[2][MainLoop];
1887       NXPhiEta1[3][MainLoop]=NXPhi[3][MainLoop];
1888       NXPhiEta2[2][MainLoop]=NXPhi[2][MainLoop];
1889       NXPhiEta2[3][MainLoop]=NXPhi[3][MainLoop];
1890       AXPhiEta[2][MainLoop]=NXPhi[2][MainLoop];
1891       AXPhiEta[3][MainLoop]=NXPhi[2][MainLoop];
1892     }
1893     
1894   }//Sould end mainloop
1895   //right now only finish up normal spectra and zT with assoc/trigger pt maybe do the assoc/near-side pt auch
1896   //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)
1897   //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
1898   if(APtTPtMult==0){
1899     if(HorizontalErrors==0){
1900       for(int mloop=0;mloop<nMainLoop;mloop++){
1901         NXPhi[1][mloop]=0;
1902         NXPhi[3][mloop]=0;
1903         NXPhi[5][mloop]=0;
1904         NXPhi[7][mloop]=0;
1905         NXPhi[9][mloop]=0;
1906         NXPhi[11][mloop]=0;
1907         NXPhi[13][mloop]=0;
1908         NXPhi[15][mloop]=0;
1909         NXPhi[17][mloop]=0;
1910         AXPhi[1][mloop]=0;
1911         AXPhi[3][mloop]=0;
1912         AXPhi[5][mloop]=0;
1913         AXPhi[7][mloop]=0;
1914         AXPhi[9][mloop]=0;
1915         AXPhi[11][mloop]=0;
1916         AXPhi[13][mloop]=0;
1917         AXPhi[15][mloop]=0;
1918         AXPhi[17][mloop]=0;
1919         NXPhiFit[1][mloop]=0;
1920         NXPhiFit[3][mloop]=0;
1921         NXPhiFit[5][mloop]=0;
1922         NXPhiFit[7][mloop]=0;
1923         NXPhiFit[9][mloop]=0;
1924         NXPhiFit[11][mloop]=0;
1925         NXPhiFit[13][mloop]=0;
1926         NXPhiFit[15][mloop]=0;
1927         NXPhiFit[17][mloop]=0;
1928         AXPhiFit[1][mloop]=0;
1929         AXPhiFit[3][mloop]=0;
1930         AXPhiFit[5][mloop]=0;
1931         AXPhiFit[7][mloop]=0;
1932         AXPhiFit[9][mloop]=0;
1933         AXPhiFit[11][mloop]=0;
1934         AXPhiFit[13][mloop]=0;
1935         AXPhiFit[15][mloop]=0;
1936         AXPhiFit[17][mloop]=0;
1937         NXEta[1][mloop]=0;
1938         NXEta[3][mloop]=0;
1939         NXEta[5][mloop]=0;
1940         NXEta[7][mloop]=0;
1941         NXEta[9][mloop]=0;
1942         NXEta[11][mloop]=0;
1943         NXEta[13][mloop]=0;
1944         NXEta[15][mloop]=0;
1945         NXEta[17][mloop]=0;
1946         AXEta[1][mloop]=0;
1947         AXEta[3][mloop]=0;
1948         AXEta[5][mloop]=0;
1949         AXEta[7][mloop]=0;
1950         AXEta[9][mloop]=0;
1951         AXEta[11][mloop]=0;
1952         AXEta[13][mloop]=0;
1953         AXEta[15][mloop]=0;
1954         AXEta[17][mloop]=0;
1955         NXEtaFit[1][mloop]=0;
1956         NXEtaFit[3][mloop]=0;
1957         NXEtaFit[5][mloop]=0;
1958         NXEtaFit[7][mloop]=0;
1959         NXEtaFit[9][mloop]=0;
1960         NXEtaFit[11][mloop]=0;
1961         NXEtaFit[13][mloop]=0;
1962         NXEtaFit[15][mloop]=0;
1963         NXEtaFit[17][mloop]=0;
1964         AXEtaFit[1][mloop]=0;
1965         AXEtaFit[3][mloop]=0;
1966         AXEtaFit[5][mloop]=0;
1967         AXEtaFit[7][mloop]=0;
1968         AXEtaFit[9][mloop]=0;
1969         AXEtaFit[11][mloop]=0;
1970         AXEtaFit[13][mloop]=0;
1971         AXEtaFit[15][mloop]=0;
1972         AXEtaFit[17][mloop]=0;
1973       }
1974     }
1975     gNPhiSpectraZYAM1=new TGraphErrors(nMainLoop,NXPhi[0],NYieldPhiZYAM[4],NXPhi[1],NYieldPhiZYAM[5]); 
1976     gNPhiSpectraZYAM2=new TGraphErrors(nMainLoop,NXPhi[2],NYieldPhiZYAM[4],NXPhi[3],NYieldPhiZYAM[5]); 
1977     gNPhiSpectraZYAM3=new TGraphErrors(nMainLoop,NXPhi[4],NYieldPhiZYAM[4],NXPhi[5],NYieldPhiZYAM[5]); 
1978     gAPhiSpectraZYAM1=new TGraphErrors(nMainLoop,AXPhi[0],AYieldPhiZYAM[4],AXPhi[1],AYieldPhiZYAM[5]); 
1979     gAPhiSpectraZYAM2=new TGraphErrors(nMainLoop,AXPhi[2],AYieldPhiZYAM[4],AXPhi[3],AYieldPhiZYAM[5]); 
1980     gAPhiSpectraZYAM3=new TGraphErrors(nMainLoop,AXPhi[4],AYieldPhiZYAM[4],AXPhi[5],AYieldPhiZYAM[5]); 
1981
1982     gNPhiZt1ZYAM1=new TGraphErrors(nMainLoop,NXPhi[6],NYieldPhiZYAM[6],NXPhi[7],NYieldPhiZYAM[7]); 
1983     gNPhiZt1ZYAM2=new TGraphErrors(nMainLoop,NXPhi[8],NYieldPhiZYAM[6],NXPhi[9],NYieldPhiZYAM[7]); 
1984     gNPhiZt1ZYAM3=new TGraphErrors(nMainLoop,NXPhi[10],NYieldPhiZYAM[6],NXPhi[11],NYieldPhiZYAM[7]); 
1985     gAPhiZt1ZYAM1=new TGraphErrors(nMainLoop,AXPhi[6],AYieldPhiZYAM[6],AXPhi[7],AYieldPhiZYAM[7]); 
1986     gAPhiZt1ZYAM2=new TGraphErrors(nMainLoop,AXPhi[8],AYieldPhiZYAM[6],AXPhi[9],AYieldPhiZYAM[7]); 
1987     gAPhiZt1ZYAM3=new TGraphErrors(nMainLoop,AXPhi[10],AYieldPhiZYAM[6],AXPhi[11],AYieldPhiZYAM[7]); 
1988
1989     gNPhiZt2ZYAM1=new TGraphErrors(nMainLoop,NXPhi[12],NYieldPhiZYAM[8],NXPhi[13],NYieldPhiZYAM[9]); 
1990     gNPhiZt2ZYAM2=new TGraphErrors(nMainLoop,NXPhi[14],NYieldPhiZYAM[8],NXPhi[15],NYieldPhiZYAM[9]); 
1991     gNPhiZt2ZYAM3=new TGraphErrors(nMainLoop,NXPhi[16],NYieldPhiZYAM[8],NXPhi[17],NYieldPhiZYAM[9]); 
1992     gAPhiZt2ZYAM1=new TGraphErrors(nMainLoop,AXPhi[12],AYieldPhiZYAM[8],AXPhi[13],AYieldPhiZYAM[9]); 
1993     gAPhiZt2ZYAM2=new TGraphErrors(nMainLoop,AXPhi[14],AYieldPhiZYAM[8],AXPhi[15],AYieldPhiZYAM[9]); 
1994     gAPhiZt2ZYAM3=new TGraphErrors(nMainLoop,AXPhi[16],AYieldPhiZYAM[8],AXPhi[17],AYieldPhiZYAM[9]); 
1995     // cout << "NXPhiFit[2] " << NXPhiFit[2][0] << " " << NXPhiFit[2][1] << endl;
1996     gNPhiSpectraFit1=new TGraphErrors(nMainLoop,NXPhiFit[0],NYieldPhiFit[4],NXPhiFit[1],NYieldPhiFit[5]); 
1997     gNPhiSpectraFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],NYieldPhiFit[4],NXPhiFit[3],NYieldPhiFit[5]); 
1998     gNPhiSpectraFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],NYieldPhiFit[4],NXPhiFit[5],NYieldPhiFit[5]); 
1999     gAPhiSpectraFit1=new TGraphErrors(nMainLoop,AXPhiFit[0],AYieldPhiFit[4],AXPhiFit[1],AYieldPhiFit[5]); 
2000     gAPhiSpectraFit2=new TGraphErrors(nMainLoop,AXPhiFit[2],AYieldPhiFit[4],AXPhiFit[3],AYieldPhiFit[5]); 
2001     gAPhiSpectraFit3=new TGraphErrors(nMainLoop,AXPhiFit[4],AYieldPhiFit[4],AXPhiFit[5],AYieldPhiFit[5]); 
2002
2003     gNPhiZt1Fit1=new TGraphErrors(nMainLoop,NXPhiFit[6],NYieldPhiFit[6],NXPhiFit[7],NYieldPhiFit[7]); 
2004     gNPhiZt1Fit2=new TGraphErrors(nMainLoop,NXPhiFit[8],NYieldPhiFit[6],NXPhiFit[9],NYieldPhiFit[7]); 
2005     gNPhiZt1Fit3=new TGraphErrors(nMainLoop,NXPhiFit[10],NYieldPhiFit[6],NXPhiFit[11],NYieldPhiFit[7]); 
2006     gAPhiZt1Fit1=new TGraphErrors(nMainLoop,AXPhiFit[6],AYieldPhiFit[6],AXPhiFit[7],AYieldPhiFit[7]); 
2007     gAPhiZt1Fit2=new TGraphErrors(nMainLoop,AXPhiFit[8],AYieldPhiFit[6],AXPhiFit[9],AYieldPhiFit[7]); 
2008     gAPhiZt1Fit3=new TGraphErrors(nMainLoop,AXPhiFit[10],AYieldPhiFit[6],AXPhiFit[11],AYieldPhiFit[7]); 
2009
2010     gNPhiWidth1=new TGraphErrors(nMainLoop,NXPhiFit[0],NWidthPhi[0],NXPhiFit[1],NWidthPhi[1]);
2011     gNPhiWidth2=new TGraphErrors(nMainLoop,NXPhiFit[2],NWidthPhi[0],NXPhiFit[3],NWidthPhi[1]);
2012     gNPhiWidth3=new TGraphErrors(nMainLoop,NXPhiFit[4],NWidthPhi[0],NXPhiFit[5],NWidthPhi[1]);
2013     gAPhiWidth1=new TGraphErrors(nMainLoop,AXPhiFit[0],AWidthPhi[0],AXPhiFit[1],AWidthPhi[1]);
2014     gAPhiWidth2=new TGraphErrors(nMainLoop,AXPhiFit[2],AWidthPhi[0],AXPhiFit[3],AWidthPhi[1]);
2015     gAPhiWidth3=new TGraphErrors(nMainLoop,AXPhiFit[4],AWidthPhi[0],AXPhiFit[5],AWidthPhi[1]);
2016
2017
2018     gNEtaSpectraZYAM1=new TGraphErrors(nMainLoop,NXEta[0],NYieldEtaZYAM[4],NXEta[1],NYieldEtaZYAM[5]); 
2019     gNEtaSpectraZYAM2=new TGraphErrors(nMainLoop,NXEta[2],NYieldEtaZYAM[4],NXEta[3],NYieldEtaZYAM[5]); 
2020     gNEtaSpectraZYAM3=new TGraphErrors(nMainLoop,NXEta[4],NYieldEtaZYAM[4],NXEta[5],NYieldEtaZYAM[5]); 
2021     gAEtaSpectraZYAM1=new TGraphErrors(nMainLoop,AXEta[0],AYieldEtaZYAM[4],AXEta[1],AYieldEtaZYAM[5]); 
2022     gAEtaSpectraZYAM2=new TGraphErrors(nMainLoop,AXEta[2],AYieldEtaZYAM[4],AXEta[3],AYieldEtaZYAM[5]); 
2023     gAEtaSpectraZYAM3=new TGraphErrors(nMainLoop,AXEta[4],AYieldEtaZYAM[4],AXEta[5],AYieldEtaZYAM[5]); 
2024
2025     gNEtaZt1ZYAM1=new TGraphErrors(nMainLoop,NXEta[6],NYieldEtaZYAM[6],NXEta[7],NYieldEtaZYAM[7]); 
2026     gNEtaZt1ZYAM2=new TGraphErrors(nMainLoop,NXEta[8],NYieldEtaZYAM[6],NXEta[9],NYieldEtaZYAM[7]); 
2027     gNEtaZt1ZYAM3=new TGraphErrors(nMainLoop,NXEta[10],NYieldEtaZYAM[6],NXEta[11],NYieldEtaZYAM[7]); 
2028     gAEtaZt1ZYAM1=new TGraphErrors(nMainLoop,AXEta[6],AYieldEtaZYAM[6],AXEta[7],AYieldEtaZYAM[7]); 
2029     gAEtaZt1ZYAM2=new TGraphErrors(nMainLoop,AXEta[8],AYieldEtaZYAM[6],AXEta[9],AYieldEtaZYAM[7]); 
2030     gAEtaZt1ZYAM3=new TGraphErrors(nMainLoop,AXEta[10],AYieldEtaZYAM[6],AXEta[11],AYieldEtaZYAM[7]); 
2031
2032     gNEtaZt2ZYAM1=new TGraphErrors(nMainLoop,NXEta[12],NYieldEtaZYAM[8],NXEta[13],NYieldEtaZYAM[9]); 
2033     gNEtaZt2ZYAM2=new TGraphErrors(nMainLoop,NXEta[14],NYieldEtaZYAM[8],NXEta[15],NYieldEtaZYAM[9]); 
2034     gNEtaZt2ZYAM3=new TGraphErrors(nMainLoop,NXEta[16],NYieldEtaZYAM[8],NXEta[17],NYieldEtaZYAM[9]); 
2035     gAEtaZt2ZYAM1=new TGraphErrors(nMainLoop,AXEta[12],AYieldEtaZYAM[8],AXEta[13],AYieldEtaZYAM[9]); 
2036     gAEtaZt2ZYAM2=new TGraphErrors(nMainLoop,AXEta[14],AYieldEtaZYAM[8],AXEta[15],AYieldEtaZYAM[9]); 
2037     gAEtaZt2ZYAM3=new TGraphErrors(nMainLoop,AXEta[16],AYieldEtaZYAM[8],AXEta[17],AYieldEtaZYAM[9]); 
2038
2039     gNEtaSpectraFit1=new TGraphErrors(nMainLoop,NXEtaFit[0],NYieldEtaFit[4],NXEtaFit[1],NYieldEtaFit[5]); 
2040     //cout << "NXEtaFit[2] " << NXEtaFit[2][0] << " " << NXEtaFit[2][1] << endl;
2041     gNEtaSpectraFit2=new TGraphErrors(nMainLoop,NXEtaFit[2],NYieldEtaFit[4],NXEtaFit[3],NYieldEtaFit[5]); 
2042     gNEtaSpectraFit3=new TGraphErrors(nMainLoop,NXEtaFit[4],NYieldEtaFit[4],NXEtaFit[5],NYieldEtaFit[5]); 
2043     gAEtaSpectraFit1=new TGraphErrors(nMainLoop,AXEtaFit[0],AYieldEtaFit[4],AXEtaFit[1],AYieldEtaFit[5]); 
2044     gAEtaSpectraFit2=new TGraphErrors(nMainLoop,AXEtaFit[2],AYieldEtaFit[4],AXEtaFit[3],AYieldEtaFit[5]); 
2045     gAEtaSpectraFit3=new TGraphErrors(nMainLoop,AXEtaFit[4],AYieldEtaFit[4],AXEtaFit[5],AYieldEtaFit[5]); 
2046
2047     gNEtaZt1Fit1=new TGraphErrors(nMainLoop,NXEtaFit[6],NYieldEtaFit[6],NXEtaFit[7],NYieldEtaFit[7]); 
2048     gNEtaZt1Fit2=new TGraphErrors(nMainLoop,NXEtaFit[8],NYieldEtaFit[6],NXEtaFit[9],NYieldEtaFit[7]); 
2049     gNEtaZt1Fit3=new TGraphErrors(nMainLoop,NXEtaFit[10],NYieldEtaFit[6],NXEtaFit[11],NYieldEtaFit[7]); 
2050     gAEtaZt1Fit1=new TGraphErrors(nMainLoop,AXEtaFit[6],AYieldEtaFit[6],AXEtaFit[7],AYieldEtaFit[7]); 
2051     gAEtaZt1Fit2=new TGraphErrors(nMainLoop,AXEtaFit[8],AYieldEtaFit[6],AXEtaFit[9],AYieldEtaFit[7]); 
2052     gAEtaZt1Fit3=new TGraphErrors(nMainLoop,AXEtaFit[10],AYieldEtaFit[6],AXEtaFit[11],AYieldEtaFit[7]); 
2053
2054     gNEtaWidth1=new TGraphErrors(nMainLoop,NXEtaFit[0],NWidthEta[0],NXEtaFit[1],NWidthEta[1]);
2055     gNEtaWidth2=new TGraphErrors(nMainLoop,NXEtaFit[2],NWidthEta[0],NXEtaFit[3],NWidthEta[1]);
2056     gNEtaWidth3=new TGraphErrors(nMainLoop,NXEtaFit[4],NWidthEta[0],NXEtaFit[5],NWidthEta[1]);
2057   
2058     float plotmin=100, plotmax=-100;
2059     float plotminW=100,plotmaxW=-100;
2060     float plotminZt=100, plotmaxZt=-100;
2061     // cout << plotmin << endl;
2062     for(int i=4;i<=8;i+=2){
2063       for(int j=0;j<nMainLoop;j++){
2064         if(NYieldPhiZYAM[i][j]<plotmin&&NYieldPhiZYAM[i][j]>0)plotmin=NYieldPhiZYAM[i][j];
2065         if(NYieldPhiZYAM[i][j]>plotmax&&NYieldPhiZYAM[i][j]>0)plotmax=NYieldPhiZYAM[i][j];
2066         if(AYieldPhiZYAM[i][j]<plotmin&&AYieldPhiZYAM[i][j]>0)plotmin=AYieldPhiZYAM[i][j];
2067         if(AYieldPhiZYAM[i][j]>plotmax&&AYieldPhiZYAM[i][j]>0)plotmax=AYieldPhiZYAM[i][j];
2068         if(NYieldEtaZYAM[i][j]<plotmin&&NYieldEtaZYAM[i][j]>0)plotmin=NYieldEtaZYAM[i][j];
2069         if(NYieldEtaZYAM[i][j]>plotmax&&NYieldEtaZYAM[i][j]>0)plotmax=NYieldEtaZYAM[i][j];
2070         if(AYieldEtaZYAM[i][j]<plotmin&&AYieldEtaZYAM[i][j]>0)plotmin=AYieldEtaZYAM[i][j];
2071         if(AYieldEtaZYAM[i][j]>plotmax&&AYieldEtaZYAM[i][j]>0)plotmax=AYieldEtaZYAM[i][j];
2072         
2073         if(i==6){
2074           if(NYieldPhiZYAM[i][j]<plotminZt&&NYieldPhiZYAM[i][j]>0)plotminZt=NYieldPhiZYAM[i][j];
2075           if(NYieldPhiZYAM[i][j]>plotmaxZt&&NYieldPhiZYAM[i][j]>0)plotmaxZt=NYieldPhiZYAM[i][j];
2076           if(AYieldPhiZYAM[i][j]<plotminZt&&AYieldPhiZYAM[i][j]>0)plotminZt=AYieldPhiZYAM[i][j];
2077           if(AYieldPhiZYAM[i][j]>plotmaxZt&&AYieldPhiZYAM[i][j]>0)plotmaxZt=AYieldPhiZYAM[i][j];
2078           /*
2079           if(NYieldEtaZYAM[i][j]<plotminZt&&NYieldEtaZYAM[i][j]>0)plotminZt=NYieldEtaZYAM[i][j];
2080           if(NYieldEtaZYAM[i][j]>plotmaxZt&&NYieldEtaZYAM[i][j]>0)plotmaxZt=NYieldEtaZYAM[i][j];
2081           if(AYieldEtaZYAM[i][j]<plotminZt&&AYieldEtaZYAM[i][j]>0)plotminZt=AYieldEtaZYAM[i][j];
2082           if(AYieldEtaZYAM[i][j]>plotmaxZt&&AYieldEtaZYAM[i][j]>0)plotmaxZt=AYieldEtaZYAM[i][j];
2083           */
2084         }
2085
2086         if(DrawFit){
2087           if(NYieldPhiFit[i][j]<plotmin&&NYieldPhiFit[i][j]>0)plotmin=NYieldPhiFit[i][j];
2088           if(NYieldPhiFit[i][j]>plotmax&&NYieldPhiFit[i][j]>0)plotmax=NYieldPhiFit[i][j];
2089           if(AYieldPhiFit[i][j]<plotmin&&AYieldPhiFit[i][j]>0)plotmin=AYieldPhiFit[i][j];
2090           if(AYieldPhiFit[i][j]>plotmax&&AYieldPhiFit[i][j]>0)plotmax=AYieldPhiFit[i][j];
2091         }
2092         if(i==4){
2093           if(NWidthPhi[0][j]<plotminW)plotminW=NWidthPhi[0][j];
2094           if(NWidthPhi[0][j]>plotmaxW&&NWidthPhi[0][j]<5)plotmaxW=NWidthPhi[0][j];
2095           if(AWidthPhi[0][j]<plotminW)plotminW=AWidthPhi[0][j];
2096           if(AWidthPhi[0][j]>plotmaxW&&AWidthPhi[0][j]<5)plotmaxW=AWidthPhi[0][j];
2097           if(NWidthEta[0][j]<plotminW)plotminW=NWidthEta[0][j];
2098           if(NWidthEta[0][j]>plotmaxW&&NWidthEta[0][j]<5)plotmaxW=NWidthEta[0][j];
2099         }
2100       }
2101     }
2102     plotmin/=2;
2103     plotmax*=100+1;
2104     plotminZt/=2;
2105     plotmaxZt*=2.2;
2106     //cout << plotmin << endl;
2107     //if(plotmin<=0)plotmin=0.0001;
2108     plotminW=0;
2109     plotmaxW*=1.1;
2110     plotmaxW=1;
2111
2112     gNPhiSpectraZYAM1->SetMarkerStyle(MarkerNearPhi);
2113     gNPhiSpectraZYAM1->SetMarkerSize(MarkerSize);
2114     gNPhiSpectraZYAM1->SetMarkerColor(ColorNearPhi);
2115     gNPhiSpectraZYAM1->SetLineColor(ColorNearPhi);
2116     gNPhiSpectraZYAM2->SetMarkerStyle(MarkerNearPhi);
2117     gNPhiSpectraZYAM2->SetMarkerSize(MarkerSize);
2118     gNPhiSpectraZYAM2->SetMarkerColor(ColorNearPhi);
2119     gNPhiSpectraZYAM2->SetLineColor(ColorNearPhi);
2120     gNPhiSpectraZYAM3->SetMarkerStyle(MarkerNearPhi);
2121     gNPhiSpectraZYAM3->SetMarkerSize(MarkerSize);
2122     gNPhiSpectraZYAM3->SetMarkerColor(ColorNearPhi);
2123     gNPhiSpectraZYAM3->SetLineColor(ColorNearPhi);
2124     gNPhiZt1ZYAM1->SetMarkerStyle(MarkerNearPhi);
2125     gNPhiZt1ZYAM1->SetMarkerSize(MarkerSize);
2126     gNPhiZt1ZYAM1->SetLineColor(ColorNearPhi);
2127     gNPhiZt1ZYAM1->SetMarkerColor(ColorNearPhi);
2128     gNPhiZt1ZYAM2->SetMarkerStyle(MarkerNearPhi);
2129     gNPhiZt1ZYAM2->SetMarkerSize(MarkerSize);
2130     gNPhiZt1ZYAM2->SetLineColor(ColorNearPhi);
2131     gNPhiZt1ZYAM2->SetMarkerColor(ColorNearPhi);
2132     gNPhiZt1ZYAM3->SetMarkerStyle(MarkerNearPhi);
2133     gNPhiZt1ZYAM3->SetMarkerSize(MarkerSize);
2134     gNPhiZt1ZYAM3->SetLineColor(ColorNearPhi);
2135     gNPhiZt1ZYAM3->SetMarkerColor(ColorNearPhi);
2136     gNPhiZt2ZYAM3->SetMarkerStyle(MarkerNearPhi);
2137     gNPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
2138     gNPhiZt2ZYAM1->SetLineColor(ColorNearPhi);
2139     gNPhiZt2ZYAM1->SetMarkerColor(ColorNearPhi);
2140     gNPhiZt2ZYAM2->SetMarkerStyle(MarkerNearPhi);
2141     gNPhiZt2ZYAM2->SetMarkerSize(MarkerSize);
2142     gNPhiZt2ZYAM2->SetLineColor(ColorNearPhi);
2143     gNPhiZt2ZYAM2->SetMarkerColor(ColorNearPhi);
2144     gNPhiZt2ZYAM3->SetMarkerStyle(MarkerNearPhi);
2145     gNPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
2146     gNPhiZt2ZYAM3->SetLineColor(ColorNearPhi);
2147     gNPhiZt2ZYAM3->SetMarkerColor(ColorNearPhi);
2148
2149     gAPhiSpectraZYAM1->SetMarkerStyle(MarkerAwayPhi);
2150     gAPhiSpectraZYAM1->SetMarkerSize(MarkerSize);
2151     gAPhiSpectraZYAM1->SetMarkerColor(ColorAwayPhi);
2152     gAPhiSpectraZYAM1->SetLineColor(ColorAwayPhi);
2153     gAPhiSpectraZYAM2->SetMarkerStyle(MarkerAwayPhi);
2154     gAPhiSpectraZYAM2->SetMarkerSize(MarkerSize);
2155     gAPhiSpectraZYAM2->SetMarkerColor(ColorAwayPhi);
2156     gAPhiSpectraZYAM2->SetLineColor(ColorAwayPhi);
2157     gAPhiSpectraZYAM3->SetMarkerStyle(MarkerAwayPhi);
2158     gAPhiSpectraZYAM3->SetMarkerSize(MarkerSize);
2159     gAPhiSpectraZYAM3->SetMarkerColor(ColorAwayPhi);
2160     gAPhiSpectraZYAM3->SetLineColor(ColorAwayPhi);
2161     gAPhiZt1ZYAM1->SetMarkerStyle(MarkerAwayPhi);
2162     gAPhiZt1ZYAM1->SetMarkerSize(MarkerSize);
2163     gAPhiZt1ZYAM1->SetLineColor(ColorAwayPhi);
2164     gAPhiZt1ZYAM1->SetMarkerColor(ColorAwayPhi);
2165     gAPhiZt1ZYAM2->SetMarkerStyle(MarkerAwayPhi);
2166     gAPhiZt1ZYAM2->SetMarkerSize(MarkerSize);
2167     gAPhiZt1ZYAM2->SetLineColor(ColorAwayPhi);
2168     gAPhiZt1ZYAM2->SetMarkerColor(ColorAwayPhi);
2169     gAPhiZt1ZYAM3->SetMarkerStyle(MarkerAwayPhi);
2170     gAPhiZt1ZYAM3->SetMarkerSize(MarkerSize);
2171     gAPhiZt1ZYAM3->SetLineColor(ColorAwayPhi);
2172     gAPhiZt1ZYAM3->SetMarkerColor(ColorAwayPhi);
2173     gAPhiZt2ZYAM3->SetMarkerStyle(MarkerAwayPhi);
2174     gAPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
2175     gAPhiZt2ZYAM1->SetLineColor(ColorAwayPhi);
2176     gAPhiZt2ZYAM1->SetMarkerColor(ColorAwayPhi);
2177     gAPhiZt2ZYAM2->SetMarkerStyle(MarkerAwayPhi);
2178     gAPhiZt2ZYAM2->SetMarkerSize(MarkerSize);
2179     gAPhiZt2ZYAM2->SetLineColor(ColorAwayPhi);
2180     gAPhiZt2ZYAM2->SetMarkerColor(ColorAwayPhi);
2181     gAPhiZt2ZYAM3->SetMarkerStyle(MarkerAwayPhi);
2182     gAPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
2183     gAPhiZt2ZYAM3->SetLineColor(ColorAwayPhi);
2184     gAPhiZt2ZYAM3->SetMarkerColor(ColorAwayPhi);
2185
2186     gNPhiSpectraFit1->SetMarkerStyle(MarkerNearPhiFit);
2187     gNPhiSpectraFit1->SetMarkerSize(MarkerSize);
2188     gNPhiSpectraFit1->SetMarkerColor(ColorNearPhiFit);
2189     gNPhiSpectraFit1->SetLineColor(ColorNearPhiFit);
2190     gNPhiSpectraFit2->SetMarkerStyle(MarkerNearPhiFit);
2191     gNPhiSpectraFit2->SetMarkerSize(MarkerSize);
2192     gNPhiSpectraFit2->SetMarkerColor(ColorNearPhiFit);
2193     gNPhiSpectraFit2->SetLineColor(ColorNearPhiFit);
2194     gNPhiSpectraFit3->SetMarkerStyle(MarkerNearPhiFit);
2195     gNPhiSpectraFit3->SetMarkerSize(MarkerSize);
2196     gNPhiSpectraFit3->SetMarkerColor(ColorNearPhiFit);
2197     gNPhiSpectraFit3->SetLineColor(ColorNearPhiFit);
2198     gNPhiZt1Fit1->SetMarkerStyle(MarkerNearPhiFit);
2199     gNPhiZt1Fit1->SetMarkerSize(MarkerSize);
2200     gNPhiZt1Fit1->SetLineColor(ColorNearPhiFit);
2201     gNPhiZt1Fit1->SetMarkerColor(ColorNearPhiFit);
2202     gNPhiZt1Fit2->SetMarkerStyle(MarkerNearPhiFit);
2203     gNPhiZt1Fit2->SetMarkerSize(MarkerSize);
2204     gNPhiZt1Fit2->SetLineColor(ColorNearPhiFit);
2205     gNPhiZt1Fit2->SetMarkerColor(ColorNearPhiFit);
2206     gNPhiZt1Fit3->SetMarkerStyle(MarkerNearPhiFit);
2207     gNPhiZt1Fit3->SetMarkerSize(MarkerSize);
2208     gNPhiZt1Fit3->SetLineColor(ColorNearPhiFit);
2209     gNPhiZt1Fit3->SetMarkerColor(ColorNearPhiFit);
2210     /*
2211       gNPhiZt2Fit3->SetMarkerStyle(24);
2212       gNPhiZt2Fit1->SetLineColor(kBlue+3);
2213       gNPhiZt2Fit1->SetMarkerColor(kBlue+3);
2214       gNPhiZt2Fit2->SetMarkerStyle(24);
2215       gNPhiZt2Fit2->SetLineColor(kBlue+3);
2216       gNPhiZt2Fit2->SetMarkerColor(kBlue+3);
2217       gNPhiZt2Fit3->SetMarkerStyle(24);
2218       gNPhiZt2Fit3->SetLineColor(kBlue+3);
2219       gNPhiZt2Fit3->SetMarkerColor(kBlue+3);
2220     */
2221     gAPhiSpectraFit1->SetMarkerStyle(MarkerAwayPhiFit);
2222     gAPhiSpectraFit1->SetMarkerSize(MarkerSize);
2223     gAPhiSpectraFit1->SetMarkerColor(ColorAwayPhiFit);
2224     gAPhiSpectraFit1->SetLineColor(ColorAwayPhiFit);
2225     gAPhiSpectraFit2->SetMarkerStyle(MarkerAwayPhiFit);
2226     gAPhiSpectraFit2->SetMarkerSize(MarkerSize);
2227     gAPhiSpectraFit2->SetMarkerColor(ColorAwayPhiFit);
2228     gAPhiSpectraFit2->SetLineColor(ColorAwayPhiFit);
2229     gAPhiSpectraFit3->SetMarkerStyle(MarkerAwayPhiFit);
2230     gAPhiSpectraFit3->SetMarkerSize(MarkerSize);
2231     gAPhiSpectraFit3->SetMarkerColor(ColorAwayPhiFit);
2232     gAPhiSpectraFit3->SetLineColor(ColorAwayPhiFit);
2233     gAPhiZt1Fit1->SetMarkerStyle(MarkerAwayPhiFit);
2234     gAPhiZt1Fit1->SetMarkerSize(MarkerSize);
2235     gAPhiZt1Fit1->SetLineColor(ColorAwayPhiFit);
2236     gAPhiZt1Fit1->SetMarkerColor(ColorAwayPhiFit);
2237     gAPhiZt1Fit2->SetMarkerStyle(MarkerAwayPhiFit);
2238     gAPhiZt1Fit2->SetMarkerSize(MarkerSize);
2239     gAPhiZt1Fit2->SetLineColor(ColorAwayPhiFit);
2240     gAPhiZt1Fit2->SetMarkerColor(ColorAwayPhiFit);
2241     gAPhiZt1Fit3->SetMarkerStyle(MarkerAwayPhiFit);
2242     gAPhiZt1Fit3->SetMarkerSize(MarkerSize);
2243     gAPhiZt1Fit3->SetLineColor(ColorAwayPhiFit);
2244     gAPhiZt1Fit3->SetMarkerColor(ColorAwayPhiFit);
2245     /*
2246       gAPhiZt2Fit3->SetMarkerStyle(25);
2247       gAPhiZt2Fit1->SetLineColor(kRed+2);
2248       gAPhiZt2Fit1->SetMarkerColor(kRed+2);
2249       gAPhiZt2Fit2->SetMarkerStyle(25);
2250       gAPhiZt2Fit2->SetLineColor(kRed+2);
2251       gAPhiZt2Fit2->SetMarkerColor(kRed+2);
2252       gAPhiZt2Fit3->SetMarkerStyle(25);
2253       gAPhiZt2Fit3->SetLineColor(kRed+2);
2254       gAPhiZt2Fit3->SetMarkerColor(kRed+2);
2255     */
2256   
2257     gNPhiWidth1->SetMarkerStyle(MarkerNearPhiFit);
2258     gNPhiWidth1->SetMarkerSize(MarkerSize);
2259     gNPhiWidth1->SetMarkerColor(ColorNearPhiFit);
2260     gNPhiWidth1->SetLineColor(ColorNearPhiFit);
2261     gNPhiWidth2->SetMarkerStyle(MarkerNearPhiFit);
2262     gNPhiWidth2->SetMarkerSize(MarkerSize);
2263     gNPhiWidth2->SetMarkerColor(ColorNearPhiFit);
2264     gNPhiWidth2->SetLineColor(ColorNearPhiFit);
2265     gNPhiWidth3->SetMarkerStyle(MarkerNearPhiFit);
2266     gNPhiWidth3->SetMarkerSize(MarkerSize);
2267     gNPhiWidth3->SetMarkerColor(ColorNearPhiFit);
2268     gNPhiWidth3->SetLineColor(ColorNearPhiFit);
2269
2270     gAPhiWidth1->SetMarkerStyle(MarkerAwayPhiFit);
2271     gAPhiWidth1->SetMarkerSize(MarkerSize);
2272     gAPhiWidth1->SetMarkerColor(ColorAwayPhiFit);
2273     gAPhiWidth1->SetLineColor(ColorAwayPhiFit);
2274     gAPhiWidth2->SetMarkerStyle(MarkerAwayPhiFit);
2275     gAPhiWidth2->SetMarkerSize(MarkerSize);
2276     gAPhiWidth2->SetMarkerColor(ColorAwayPhiFit);
2277     gAPhiWidth2->SetLineColor(ColorAwayPhiFit);
2278     gAPhiWidth3->SetMarkerStyle(MarkerAwayPhiFit);
2279     gAPhiWidth3->SetMarkerSize(MarkerSize);
2280     gAPhiWidth3->SetMarkerColor(ColorAwayPhiFit);
2281     gAPhiWidth3->SetLineColor(ColorAwayPhiFit);
2282
2283
2284     gNEtaSpectraZYAM1->SetMarkerStyle(MarkerNearEta);
2285     gNEtaSpectraZYAM1->SetMarkerSize(MarkerSize);
2286     gNEtaSpectraZYAM1->SetMarkerColor(ColorNearEta);
2287     gNEtaSpectraZYAM1->SetLineColor(ColorNearEta);
2288     gNEtaSpectraZYAM2->SetMarkerStyle(MarkerNearEta);
2289     gNEtaSpectraZYAM2->SetMarkerSize(MarkerSize);
2290     gNEtaSpectraZYAM2->SetMarkerColor(ColorNearEta);
2291     gNEtaSpectraZYAM2->SetLineColor(ColorNearEta);
2292     gNEtaSpectraZYAM3->SetMarkerStyle(MarkerNearEta);
2293     gNEtaSpectraZYAM3->SetMarkerSize(MarkerSize);
2294     gNEtaSpectraZYAM3->SetMarkerColor(ColorNearEta);
2295     gNEtaSpectraZYAM3->SetLineColor(ColorNearEta);
2296     gNEtaZt1ZYAM1->SetMarkerStyle(MarkerNearEta);
2297     gNEtaZt1ZYAM1->SetMarkerSize(MarkerSize);
2298     gNEtaZt1ZYAM1->SetLineColor(ColorNearEta);
2299     gNEtaZt1ZYAM1->SetMarkerColor(ColorNearEta);
2300     gNEtaZt1ZYAM2->SetMarkerStyle(MarkerNearEta);
2301     gNEtaZt1ZYAM2->SetMarkerSize(MarkerSize);
2302     gNEtaZt1ZYAM2->SetLineColor(ColorNearEta);
2303     gNEtaZt1ZYAM2->SetMarkerColor(ColorNearEta);
2304     gNEtaZt1ZYAM3->SetMarkerStyle(MarkerNearEta);
2305     gNEtaZt1ZYAM3->SetMarkerSize(MarkerSize);
2306     gNEtaZt1ZYAM3->SetLineColor(ColorNearEta);
2307     gNEtaZt1ZYAM3->SetMarkerColor(ColorNearEta);
2308     gNEtaZt2ZYAM3->SetMarkerStyle(MarkerNearEta);
2309     gNEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
2310     gNEtaZt2ZYAM1->SetLineColor(ColorNearEta);
2311     gNEtaZt2ZYAM1->SetMarkerColor(ColorNearEta);
2312     gNEtaZt2ZYAM2->SetMarkerStyle(MarkerNearEta);
2313     gNEtaZt2ZYAM2->SetMarkerSize(MarkerSize);
2314     gNEtaZt2ZYAM2->SetLineColor(ColorNearEta);
2315     gNEtaZt2ZYAM2->SetMarkerColor(ColorNearEta);
2316     gNEtaZt2ZYAM3->SetMarkerStyle(MarkerNearEta);
2317     gNEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
2318     gNEtaZt2ZYAM3->SetLineColor(ColorNearEta);
2319     gNEtaZt2ZYAM3->SetMarkerColor(ColorNearEta);
2320
2321     gAEtaSpectraZYAM1->SetMarkerStyle(MarkerAwayEta);
2322     gAEtaSpectraZYAM1->SetMarkerSize(MarkerSize);
2323     gAEtaSpectraZYAM1->SetMarkerColor(ColorAwayEta);
2324     gAEtaSpectraZYAM1->SetLineColor(ColorAwayEta);
2325     gAEtaSpectraZYAM2->SetMarkerStyle(MarkerAwayEta);
2326     gAEtaSpectraZYAM2->SetMarkerSize(MarkerSize);
2327     gAEtaSpectraZYAM2->SetMarkerColor(ColorAwayEta);
2328     gAEtaSpectraZYAM2->SetLineColor(ColorAwayEta);
2329     gAEtaSpectraZYAM3->SetMarkerStyle(MarkerAwayEta);
2330     gAEtaSpectraZYAM3->SetMarkerSize(MarkerSize);
2331     gAEtaSpectraZYAM3->SetMarkerColor(ColorAwayEta);
2332     gAEtaSpectraZYAM3->SetLineColor(ColorAwayEta);
2333     gAEtaZt1ZYAM1->SetMarkerStyle(MarkerAwayEta);
2334     gAEtaZt1ZYAM1->SetMarkerSize(MarkerSize);
2335     gAEtaZt1ZYAM1->SetLineColor(ColorAwayEta);
2336     gAEtaZt1ZYAM1->SetMarkerColor(ColorAwayEta);
2337     gAEtaZt1ZYAM2->SetMarkerStyle(MarkerAwayEta);
2338     gAEtaZt1ZYAM2->SetMarkerSize(MarkerSize);
2339     gAEtaZt1ZYAM2->SetLineColor(ColorAwayEta);
2340     gAEtaZt1ZYAM2->SetMarkerColor(ColorAwayEta);
2341     gAEtaZt1ZYAM3->SetMarkerStyle(MarkerAwayEta);
2342     gAEtaZt1ZYAM3->SetMarkerSize(MarkerSize);
2343     gAEtaZt1ZYAM3->SetLineColor(ColorAwayEta);
2344     gAEtaZt1ZYAM3->SetMarkerColor(ColorAwayEta);
2345     gAEtaZt2ZYAM3->SetMarkerStyle(MarkerAwayEta);
2346     gAEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
2347     gAEtaZt2ZYAM1->SetLineColor(ColorAwayEta);
2348     gAEtaZt2ZYAM1->SetMarkerColor(ColorAwayEta);
2349     gAEtaZt2ZYAM2->SetMarkerStyle(MarkerAwayEta);
2350     gAEtaZt2ZYAM2->SetMarkerSize(MarkerSize);
2351     gAEtaZt2ZYAM2->SetLineColor(ColorAwayEta);
2352     gAEtaZt2ZYAM2->SetMarkerColor(ColorAwayEta);
2353     gAEtaZt2ZYAM3->SetMarkerStyle(MarkerAwayEta);
2354     gAEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
2355     gAEtaZt2ZYAM3->SetLineColor(ColorAwayEta);
2356     gAEtaZt2ZYAM3->SetMarkerColor(ColorAwayEta);
2357
2358     gNEtaSpectraFit1->SetMarkerStyle(MarkerNearEtaFit);
2359     gNEtaSpectraFit1->SetMarkerSize(MarkerSize);
2360     gNEtaSpectraFit1->SetMarkerColor(ColorNearEtaFit);
2361     gNEtaSpectraFit1->SetLineColor(ColorNearEtaFit);
2362     gNEtaSpectraFit2->SetMarkerStyle(MarkerNearEtaFit);
2363     gNEtaSpectraFit2->SetMarkerSize(MarkerSize);
2364     gNEtaSpectraFit2->SetMarkerColor(ColorNearEtaFit);
2365     gNEtaSpectraFit2->SetLineColor(ColorNearEtaFit);
2366     gNEtaSpectraFit3->SetMarkerStyle(MarkerNearEtaFit);
2367     gNEtaSpectraFit3->SetMarkerSize(MarkerSize);
2368     gNEtaSpectraFit3->SetMarkerColor(ColorNearEtaFit);
2369     gNEtaSpectraFit3->SetLineColor(ColorNearEtaFit);
2370     gNEtaZt1Fit1->SetMarkerStyle(MarkerNearEtaFit);
2371     gNEtaZt1Fit1->SetMarkerSize(MarkerSize);
2372     gNEtaZt1Fit1->SetLineColor(ColorNearEtaFit);
2373     gNEtaZt1Fit1->SetMarkerColor(ColorNearEtaFit);
2374     gNEtaZt1Fit2->SetMarkerStyle(MarkerNearEtaFit);
2375     gNEtaZt1Fit2->SetMarkerSize(MarkerSize);
2376     gNEtaZt1Fit2->SetLineColor(ColorNearEtaFit);
2377     gNEtaZt1Fit2->SetMarkerColor(ColorNearEtaFit);
2378     gNEtaZt1Fit3->SetMarkerStyle(MarkerNearEtaFit);
2379     gNEtaZt1Fit3->SetMarkerSize(MarkerSize);
2380     gNEtaZt1Fit3->SetLineColor(ColorNearEtaFit);
2381     gNEtaZt1Fit3->SetMarkerColor(ColorNearEtaFit);
2382
2383     gNEtaWidth1->SetMarkerStyle(MarkerNearEtaFit);
2384     gNEtaWidth1->SetMarkerSize(MarkerSize);
2385     gNEtaWidth1->SetMarkerColor(ColorNearEtaFit);
2386     gNEtaWidth1->SetLineColor(ColorNearEtaFit);
2387     gNEtaWidth2->SetMarkerStyle(MarkerNearEtaFit);
2388     gNEtaWidth2->SetMarkerSize(MarkerSize);
2389     gNEtaWidth2->SetMarkerColor(ColorNearEtaFit);
2390     gNEtaWidth2->SetLineColor(ColorNearEtaFit);
2391     gNEtaWidth3->SetMarkerStyle(MarkerNearEtaFit);
2392     gNEtaWidth3->SetMarkerSize(MarkerSize);
2393     gNEtaWidth3->SetMarkerColor(ColorNearEtaFit);
2394     gNEtaWidth3->SetLineColor(ColorNearEtaFit);
2395
2396   
2397     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]);
2398     TFile *fout=new TFile(name,"recreate");
2399
2400
2401     cSpectraZYAM1=new TCanvas("cSpectraZYAM1","Spectra MidPoint",800,600);
2402     SetMargins1D(cSpectraZYAM1);
2403     sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2404     TH2F *hSpectraZYAM1=new TH2F("hSpectraZYAM1",name,10,0,TPt1,10,plotmin,plotmax);
2405     if(NoTitle)hSpectraZYAM1->SetTitle("");
2406     hSpectraZYAM1->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2407     hSpectraZYAM1->GetXaxis()->SetTitleColor(1);
2408     hSpectraZYAM1->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2409     SetTitles1D(hSpectraZYAM1);
2410     hSpectraZYAM1->Draw();
2411     cSpectraZYAM1->SetLogy(1);
2412     gNPhiSpectraZYAM1->Draw("p");
2413     gAPhiSpectraZYAM1->Draw("p");
2414     if(DrawFit)gNPhiSpectraFit1->Draw("p");
2415     if(DrawFit)gAPhiSpectraFit1->Draw("p");
2416     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2417     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2418     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2419     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2420     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2421     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);
2422     cSpectraZYAM1->SaveAs(outName);
2423
2424     cSpectraZYAM2=new TCanvas("cSpectraZYAM2","Spectra Average",800,600);
2425     SetMargins1D(cSpectraZYAM2);
2426     sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2427     TH2F *hSpectraZYAM2=new TH2F("hSpectraZYAM2",name,10,0,TPt1,10,plotmin,plotmax);
2428     if(NoTitle)hSpectraZYAM2->SetTitle("");
2429     hSpectraZYAM2->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2430     hSpectraZYAM2->GetXaxis()->SetTitleColor(1);
2431     hSpectraZYAM2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2432     SetTitles1D(hSpectraZYAM2);
2433     hSpectraZYAM2->Draw();
2434     cSpectraZYAM2->SetLogy(1);
2435     gNPhiSpectraZYAM2->Draw("p");
2436     gAPhiSpectraZYAM2->Draw("p");
2437     if(DrawFit)gNPhiSpectraFit2->Draw("p");
2438     if(DrawFit)gAPhiSpectraFit2->Draw("p");
2439     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2440     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2441     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2442     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2443     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2444     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);
2445     cSpectraZYAM2->SaveAs(outName);
2446
2447     cSpectraZYAM3=new TCanvas("cSpectraZYAM3","Spectra Lowest Error",800,600);
2448     SetMargins1D(cSpectraZYAM3);
2449     sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2450     TH2F *hSpectraZYAM3=new TH2F("hSpectraZYAM3",name,10,0,TPt1,10,plotmin,plotmax);
2451     if(NoTitle)hSpectraZYAM3->SetTitle("");
2452     hSpectraZYAM3->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2453     hSpectraZYAM3->GetXaxis()->SetTitleColor(1);
2454     hSpectraZYAM3->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2455     SetTitles1D(hSpectraZYAM3);
2456     hSpectraZYAM3->Draw();
2457     cSpectraZYAM3->SetLogy(1);
2458     gNPhiSpectraZYAM3->Draw("p");
2459     gAPhiSpectraZYAM3->Draw("p");
2460     if(DrawFit)gNPhiSpectraFit3->Draw("p");
2461     if(DrawFit)gAPhiSpectraFit3->Draw("p");
2462     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2463     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2464     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2465     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2466     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2467     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);
2468     cSpectraZYAM3->SaveAs(outName);
2469
2470     cZt1ZYAM1=new TCanvas("cZt1ZYAM1","Zt Spectra MidPoint",800,600);
2471     SetMargins1D(cZt1ZYAM1);
2472     sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2473     TH2F *hZt1ZYAM1=new TH2F("hZt1ZYAM1",name,10,0,1,10,plotminZt,plotmaxZt);
2474     if(NoTitle)hZt1ZYAM1->SetTitle("");
2475     hZt1ZYAM1->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
2476     hZt1ZYAM1->GetXaxis()->SetTitleColor(1);
2477     hZt1ZYAM1->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2478     SetTitles1D(hZt1ZYAM1);
2479     hZt1ZYAM1->Draw();
2480     cZt1ZYAM1->SetLogy(1);
2481     gNPhiZt1ZYAM1->Draw("p");
2482     gAPhiZt1ZYAM1->Draw("p");
2483     if(DrawFit)gNPhiZt1Fit1->Draw("p");
2484     if(DrawFit)gAPhiZt1Fit1->Draw("p");
2485     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2486     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2487     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2488     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2489     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2490     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);
2491     cZt1ZYAM1->SaveAs(outName);
2492
2493     cZt1ZYAM2=new TCanvas("cZt1ZYAM2","Zt Spectra Average",800,600);
2494     SetMargins1D(cZt1ZYAM2);
2495     sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2496     TH2F *hZt1ZYAM2=new TH2F("hZt1ZYAM2",name,10,0,1,10,plotminZt,plotmaxZt);
2497     if(NoTitle)hZt1ZYAM2->SetTitle("");
2498     hZt1ZYAM2->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
2499     hZt1ZYAM2->GetXaxis()->SetTitleColor(1);
2500     hZt1ZYAM2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2501     SetTitles1D(hZt1ZYAM2);
2502     hZt1ZYAM2->Draw();
2503     cZt1ZYAM2->SetLogy(1);
2504     gNPhiZt1ZYAM2->Draw("p");
2505     gAPhiZt1ZYAM2->Draw("p");
2506     if(DrawFit)gNPhiZt1Fit2->Draw("p");
2507     if(DrawFit)gAPhiZt1Fit2->Draw("p");
2508     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2509     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2510     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2511     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2512     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2513     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);
2514     cZt1ZYAM2->SaveAs(outName);
2515
2516     cZt1ZYAM3=new TCanvas("cZt1ZYAM3","Zt Spectra Lowest Error",800,600);
2517     SetMargins1D(cZt1ZYAM3);
2518     sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2519     TH2F *hZt1ZYAM3=new TH2F("hZt1ZYAM3",name,10,0,1,10,plotminZt,plotmaxZt);
2520     if(NoTitle)hZt1ZYAM3->SetTitle("");
2521     hZt1ZYAM3->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2522     hZt1ZYAM3->GetXaxis()->SetTitleColor(1);
2523     hZt1ZYAM3->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2524     SetTitles1D(hZt1ZYAM3);
2525     hZt1ZYAM3->Draw();
2526     cZt1ZYAM3->SetLogy(1);
2527     gNPhiZt1ZYAM3->Draw("p");
2528     gAPhiZt1ZYAM3->Draw("p");
2529     if(DrawFit)gNPhiZt1Fit3->Draw("p");
2530     if(DrawFit)gAPhiZt1Fit3->Draw("p");
2531     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2532     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2533     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2534     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2535     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2536     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);
2537     cZt1ZYAM3->SaveAs(outName);
2538   
2539     /*
2540       cZt2ZYAM1=new TCanvas("cZt2ZYAM1","Spectra MidPoint",800,600);
2541       SetMargins1D(cZt2ZYAM1);
2542       sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2543       if(NoTitle)name="";
2544       TH2F *hZt2ZYAM1=new TH2F("hZt2ZYAM1",name,10,0,1,10,plotmin,plotmax);
2545       hZt2ZYAM1->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Near}  ");
2546       hZt2ZYAM1->GetXaxis()->SetTitleColor(1);
2547       hZt2ZYAM1->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2548       hZt2ZYAM1->Draw();
2549       cZt2ZYAM1->SetLogy(1);
2550       gNPhiZt2ZYAM1->Draw("p");
2551       gAPhiZt2ZYAM1->Draw("p");
2552       gNPhiZt2Fit1->Draw("p");
2553       gAPhiZt2Fit1->Draw("p");
2554       sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2555       keySymbol(.65,.85,name,1,20,0.06,1.5);
2556       keySymbol(.65,.8,"Away",2,21,0.06,1.5);
2557       keySymbol(.65,.75,"Near Fit",kBlue+3,24,0.06,1.5);
2558       keySymbol(.65,.7,"Away Fit",kRed+2,25,0.06,1.5);
2559       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);
2560       cZt2ZYAM1->SaveAs(outName);
2561
2562       cZt2ZYAM2=new TCanvas("cZt2ZYAM2","Spectra Average",800,600);
2563       SetMargins1D(cZt2ZYAM2);
2564       sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2565       if(NoTitle)name="";
2566       TH2F *hZt2ZYAM2=new TH2F("hZt2ZYAM2",name,10,0,1,10,plotmin,plotmax);
2567       hZt2ZYAM2->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Near} (GeV/c) ");
2568       hZt2ZYAM2->GetXaxis()->SetTitleColor(1);
2569       hZt2ZYAM2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2570       hZt2ZYAM2->Draw();
2571       cZt2ZYAM2->SetLogy(1);
2572       gNPhiZt2ZYAM2->Draw("p");
2573       gAPhiZt2ZYAM2->Draw("p");
2574       gNPhiZt2Fit2->Draw("p");
2575       gAPhiZt2Fit2->Draw("p");
2576       sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2577       keySymbol(.65,.85,name,1,20,0.06,1.5);
2578       keySymbol(.65,.8,"Away",2,21,0.06,1.5);
2579       keySymbol(.65,.75,"Near Fit",kBlue+3,24,0.06,1.5);
2580       keySymbol(.65,.7,"Away Fit",kRed+2,25,0.06,1.5);
2581       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);
2582       cZt2ZYAM2->SaveAs(outName);
2583
2584       cZt2ZYAM3=new TCanvas("cZt2ZYAM3","Spectra Lowest Error",800,600);
2585       SetMargins1D(cZt2ZYAM3);
2586       sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2587       if(NoTitle)name="";
2588       TH2F *hZt2ZYAM3=new TH2F("hZt2ZYAM3",name,10,0,1,10,plotmin,plotmax);
2589       hZt2ZYAM3->GetXaxis()->SetTitle("p_{T}^{Assoc}/p_{T}^{Near} (GeV/c) ");
2590       hZt2ZYAM3->GetXaxis()->SetTitleColor(1);
2591       hZt2ZYAM3->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2592       hZt2ZYAM3->Draw();
2593       cZt2ZYAM3->SetLogy(1);
2594       gNPhiZt2ZYAM3->Draw("p");
2595       gAPhiZt2ZYAM3->Draw("p");
2596       gNPhiZt2Fit3->Draw("p");
2597       gAPhiZt2Fit3->Draw("p");
2598       sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2599       keySymbol(.65,.85,name,1,20,0.06,1.5);
2600       keySymbol(.65,.8,"Away",2,21,0.06,1.5);
2601       keySymbol(.65,.75,"Near Fit",kBlue+3,24,0.06,1.5);
2602       keySymbol(.65,.7,"Away Fit",kRed+2,25,0.06,1.5);
2603       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);
2604       cZt2ZYAM3->SaveAs(outName);
2605   
2606     */
2607
2608     cSpectraZYAM1E=new TCanvas("cSpectraZYAM1E","Spectra MidPoint",800,600);
2609     SetMargins1D(cSpectraZYAM1E);
2610     sprintf(name,"Associated Particle Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2611     TH2F *hSpectraZYAM1E=new TH2F("hSpectraZYAM1E",name,10,0,TPt1,10,plotmin,plotmax);
2612     if(NoTitle)hSpectraZYAM1E->SetTitle("");
2613     hSpectraZYAM1E->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2614     hSpectraZYAM1E->GetXaxis()->SetTitleColor(1);
2615     hSpectraZYAM1E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2616     SetTitles1D(hSpectraZYAM1E);
2617     hSpectraZYAM1E->Draw();
2618     cSpectraZYAM1E->SetLogy(1);
2619     gNEtaSpectraZYAM1->Draw("p");
2620     gAEtaSpectraZYAM1->Draw("p");
2621     if(DrawFit)gNEtaSpectraFit1->Draw("p");
2622     // if(DrawFit)gAPhiSpectraFit1->Draw("p");
2623     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
2624     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2625     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2626     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2627     // if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2628     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);
2629     cSpectraZYAM1E->SaveAs(outName);
2630
2631     cSpectraZYAM2E=new TCanvas("cSpectraZYAM2E","Spectra Average",800,600);
2632     SetMargins1D(cSpectraZYAM2E);
2633     sprintf(name,"Associated Particle Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2634     TH2F *hSpectraZYAM2E=new TH2F("hSpectraZYAM2E",name,10,0,TPt1,10,plotmin,plotmax);
2635     if(NoTitle)hSpectraZYAM2E->SetTitle("");
2636     hSpectraZYAM2E->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2637     hSpectraZYAM2E->GetXaxis()->SetTitleColor(1);
2638     hSpectraZYAM2E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2639     SetTitles1D(hSpectraZYAM2E);
2640     hSpectraZYAM2E->Draw();
2641     cSpectraZYAM2E->SetLogy(1);
2642     gNEtaSpectraZYAM2->Draw("p");
2643     gAEtaSpectraZYAM2->Draw("p");
2644     if(DrawFit)gNEtaSpectraFit2->Draw("p");
2645     //if(DrawFit)gAEtaSpectraFit2->Draw("p");
2646     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
2647     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2648     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2649     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2650     // if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
2651     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);
2652     cSpectraZYAM2E->SaveAs(outName);
2653
2654     cSpectraZYAM3E=new TCanvas("cSpectraZYAM3E","Spectra Lowest Error",800,600);
2655     SetMargins1D(cSpectraZYAM3);
2656     sprintf(name,"Associated Particle Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2657     TH2F *hSpectraZYAM3E=new TH2F("hSpectraZYAM3E",name,10,0,TPt1,10,plotmin,plotmax);
2658     if(NoTitle)hSpectraZYAM3E->SetTitle("");
2659     hSpectraZYAM3E->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2660     hSpectraZYAM3E->GetXaxis()->SetTitleColor(1);
2661     hSpectraZYAM3E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2662     SetTitles1D(hSpectraZYAM3E);
2663     hSpectraZYAM3E->Draw();
2664     cSpectraZYAM3E->SetLogy(1);
2665     gNEtaSpectraZYAM3->Draw("p");
2666     gAEtaSpectraZYAM3->Draw("p");
2667     if(DrawFit)gNEtaSpectraFit3->Draw("p");
2668     //if(DrawFit)gAEtaSpectraFit3->Draw("p");
2669     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
2670     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2671     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2672     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2673     //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
2674     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);
2675     cSpectraZYAM3E->SaveAs(outName);
2676
2677     cZt1ZYAM1E=new TCanvas("cZt1ZYAM1E","Spectra MidPoint",800,600);
2678     SetMargins1D(cZt1ZYAM1E);
2679     sprintf(name,"Associated Particle Z_{T} Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2680     TH2F *hZt1ZYAM1E=new TH2F("hZt1ZYAM1E",name,10,0,1,10,plotmin,plotmax);
2681     if(NoTitle)hZt1ZYAM1E->SetTitle("");
2682     hZt1ZYAM1E->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
2683     hZt1ZYAM1E->GetXaxis()->SetTitleColor(1);
2684     hZt1ZYAM1E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2685     SetTitles1D(hZt1ZYAM1E);
2686     hZt1ZYAM1E->Draw();
2687     cZt1ZYAM1E->SetLogy(1);
2688     gNEtaZt1ZYAM1->Draw("p");
2689     gAEtaZt1ZYAM1->Draw("p");
2690     if(DrawFit)gNEtaZt1Fit1->Draw("p");
2691     //if(DrawFit)gAEtaZt1Fit1->Draw("p");
2692     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
2693     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2694     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2695     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2696     //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
2697     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);
2698     cZt1ZYAM1E->SaveAs(outName);
2699
2700     cZt1ZYAM2E=new TCanvas("cZt1ZYAM2E","Spectra Average",800,600);
2701     SetMargins1D(cZt1ZYAM2E);
2702     sprintf(name,"Associated Particle Z_{T} Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2703     TH2F *hZt1ZYAM2E=new TH2F("hZt1ZYAM2E",name,10,0,1,10,plotmin,plotmax);
2704     if(NoTitle)hZt1ZYAM2E->SetTitle("");
2705     hZt1ZYAM2E->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
2706     hZt1ZYAM2E->GetXaxis()->SetTitleColor(1);
2707     hZt1ZYAM2E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2708     SetTitles1D(hZt1ZYAM2E);
2709     hZt1ZYAM2E->Draw();
2710     cZt1ZYAM2E->SetLogy(1);
2711     gNEtaZt1ZYAM2->Draw("p");
2712     gAEtaZt1ZYAM2->Draw("p");
2713     if(DrawFit)gNEtaZt1Fit2->Draw("p");
2714     //if(DrawFit)gAEtaZt1Fit2->Draw("p");
2715     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
2716     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2717     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2718     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2719     //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
2720     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);
2721     cZt1ZYAM2E->SaveAs(outName);
2722
2723     cZt1ZYAM3E=new TCanvas("cZt1ZYAM3E","Spectra Lowest Error",800,600);
2724     SetMargins1D(cZt1ZYAM3E);
2725     sprintf(name,"Associated Particle Z_{T} Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2726     TH2F *hZt1ZYAM3E=new TH2F("hZt1ZYAM3E",name,10,0,1,10,plotmin,plotmax);
2727     if(NoTitle)hZt1ZYAM3->SetTitle("");
2728     hZt1ZYAM3E->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2729     hZt1ZYAM3E->GetXaxis()->SetTitleColor(1);
2730     hZt1ZYAM3E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2731     SetTitles1D(hZt1ZYAM3E);
2732     hZt1ZYAM3E->Draw();
2733     cZt1ZYAM3E->SetLogy(1);
2734     gNEtaZt1ZYAM3->Draw("p");
2735     gAEtaZt1ZYAM3->Draw("p");
2736     if(DrawFit)gNEtaZt1Fit3->Draw("p");
2737     //if(DrawFit)gAEtaZt1Fit3->Draw("p");
2738     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
2739     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2740     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2741     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2742     //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
2743     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);
2744     cZt1ZYAM3E->SaveAs(outName);
2745
2746
2747     cSpectraZYAM1C=new TCanvas("cSpectraZYAM1C","Spectra MidPoint",800,600);
2748     SetMargins1D(cSpectraZYAM1C);
2749     sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2750     TH2F *hSpectraZYAM1C=new TH2F("hSpectraZYAM1C",name,10,0,TPt1,10,plotmin,plotmax);
2751     if(NoTitle)hSpectraZYAM1C->SetTitle("");
2752     hSpectraZYAM1C->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2753     hSpectraZYAM1C->GetXaxis()->SetTitleColor(1);
2754     hSpectraZYAM1C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2755     SetTitles1D(hSpectraZYAM1C);
2756     hSpectraZYAM1C->Draw();
2757     cSpectraZYAM1C->SetLogy(1);
2758     gNPhiSpectraZYAM1->Draw("p");
2759     gAPhiSpectraZYAM1->Draw("p");
2760     gNEtaSpectraZYAM1->Draw("p");
2761     gAEtaSpectraZYAM1->Draw("p");
2762     if(DrawFit)gNPhiSpectraFit1->Draw("p");
2763     if(DrawFit)gAPhiSpectraFit1->Draw("p");
2764     if(DrawFit)gNEtaSpectraFit1->Draw("p");
2765     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2766     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2767     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2768     if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2769     if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2770     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2771     keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2772     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2773     // if(DrawFit)keySymbol(.65,.7,"Away #Delta#eta Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2774     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);
2775     cSpectraZYAM1C->SaveAs(outName);
2776
2777     cSpectraZYAM2C=new TCanvas("cSpectraZYAM2C","Spectra MidPoint",800,600);
2778     SetMargins1D(cSpectraZYAM2C);
2779     sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2780     TH2F *hSpectraZYAM2C=new TH2F("hSpectraZYAM2C",name,10,0,TPt1,10,plotmin,plotmax);
2781     if(NoTitle)hSpectraZYAM2C->SetTitle("");
2782     hSpectraZYAM2C->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2783     hSpectraZYAM2C->GetXaxis()->SetTitleColor(1);
2784     hSpectraZYAM2C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2785
2786     SetTitles1D(hSpectraZYAM2C);
2787     hSpectraZYAM2C->Draw();
2788     cSpectraZYAM2C->SetLogy(1);
2789     gNPhiSpectraZYAM2->Draw("p");
2790     gAPhiSpectraZYAM2->Draw("p");
2791     gNEtaSpectraZYAM2->Draw("p");
2792     gAEtaSpectraZYAM2->Draw("p");
2793     if(DrawFit)gNPhiSpectraFit2->Draw("p");
2794     if(DrawFit)gAPhiSpectraFit2->Draw("p");
2795     if(DrawFit)gNEtaSpectraFit2->Draw("p");
2796     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2797     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2798     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2799     if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2800     if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2801     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2802     keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2803     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2804     // if(DrawFit)keySymbol(.65,.7,"Away #Delta#eta Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2805     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);
2806     cSpectraZYAM2C->SaveAs(outName);
2807
2808     cSpectraZYAM3C=new TCanvas("cSpectraZYAM3C","Spectra MidPoint",800,600);
2809     SetMargins1D(cSpectraZYAM3C);
2810     sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2811     TH2F *hSpectraZYAM3C=new TH2F("hSpectraZYAM3C",name,10,0,TPt1,10,plotmin,plotmax);
2812     if(NoTitle)hSpectraZYAM3C->SetTitle("");
2813     hSpectraZYAM3C->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
2814     hSpectraZYAM3C->GetXaxis()->SetTitleColor(1);
2815     hSpectraZYAM3C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
2816     SetTitles1D(hSpectraZYAM3C);
2817     hSpectraZYAM3C->Draw();
2818     cSpectraZYAM3C->SetLogy(1);
2819     gNPhiSpectraZYAM3->Draw("p");
2820     gAPhiSpectraZYAM3->Draw("p");
2821     gNEtaSpectraZYAM3->Draw("p");
2822     gAEtaSpectraZYAM3->Draw("p");
2823     if(DrawFit)gNPhiSpectraFit3->Draw("p");
2824     if(DrawFit)gAPhiSpectraFit3->Draw("p");
2825     if(DrawFit)gNEtaSpectraFit3->Draw("p");
2826     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2827     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2828     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2829     if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2830     if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2831     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2832     keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2833     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2834     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);
2835     cSpectraZYAM3C->SaveAs(outName);
2836
2837
2838     cZt1ZYAM1C=new TCanvas("cZt1ZYAM1C","ZT MidPoint",800,600);
2839     SetMargins1D(cZt1ZYAM1C);
2840     sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2841     TH2F *hZt1ZYAM1C=new TH2F("hZt1ZYAM1C",name,10,0,1,10,plotmin,plotmax);
2842     if(NoTitle)hZt1ZYAM1C->SetTitle("");
2843     hZt1ZYAM1C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2844     hZt1ZYAM1C->GetXaxis()->SetTitleColor(1);
2845     hZt1ZYAM1C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2846     SetTitles1D(hZt1ZYAM1C);
2847     hZt1ZYAM1C->Draw();
2848     cZt1ZYAM1C->SetLogy(1);
2849     gNPhiZt1ZYAM1->Draw("p");
2850     gAPhiZt1ZYAM1->Draw("p");
2851     gNEtaZt1ZYAM1->Draw("p");
2852     gAEtaZt1ZYAM1->Draw("p");
2853     if(DrawFit)gNPhiZt1Fit1->Draw("p");
2854     if(DrawFit)gAPhiZt1Fit1->Draw("p");
2855     if(DrawFit)gNEtaZt1Fit1->Draw("p");
2856     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2857     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2858     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2859     if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2860     if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2861     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2862     keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2863     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2864     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);
2865     cZt1ZYAM1C->SaveAs(outName);
2866
2867     cZt1ZYAM2C=new TCanvas("cZt1ZYAM2C","Zt MidPoint",800,600);
2868     SetMargins1D(cZt1ZYAM2C);
2869     sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2870     TH2F *hZt1ZYAM2C=new TH2F("hZt1ZYAM2C",name,10,0,1,10,plotmin,plotmax);
2871     if(NoTitle)hZt1ZYAM2C->SetTitle("");
2872     hZt1ZYAM2C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2873     hZt1ZYAM2C->GetXaxis()->SetTitleColor(1);
2874     hZt1ZYAM2C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2875   
2876     SetTitles1D(hZt1ZYAM2C);
2877     hZt1ZYAM2C->Draw();
2878     cZt1ZYAM2C->SetLogy(1);
2879     gNPhiZt1ZYAM2->Draw("p");
2880     gAPhiZt1ZYAM2->Draw("p");
2881     gNEtaZt1ZYAM2->Draw("p");
2882     gAEtaZt1ZYAM2->Draw("p");
2883     if(DrawFit)gNPhiZt1Fit2->Draw("p");
2884     if(DrawFit)gAPhiZt1Fit2->Draw("p");
2885     if(DrawFit)gNEtaZt1Fit2->Draw("p");
2886     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2887     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2888     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2889     if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2890     if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2891     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2892     keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2893     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2894     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);
2895     cZt1ZYAM2C->SaveAs(outName);
2896
2897     cZt1ZYAM3C=new TCanvas("cZt1ZYAM3C","Zt1_3 MidPoint",800,600);
2898     SetMargins1D(cZt1ZYAM3C);
2899     sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2900     TH2F *hZt1ZYAM3C=new TH2F("hZt1ZYAM3C",name,10,0,1,10,plotmin,plotmax);
2901     if(NoTitle)hZt1ZYAM3C->SetTitle("");
2902     hZt1ZYAM3C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2903     hZt1ZYAM3C->GetXaxis()->SetTitleColor(1);
2904     hZt1ZYAM3C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2905     SetTitles1D(hZt1ZYAM3C);
2906     hZt1ZYAM3C->Draw();
2907     cZt1ZYAM3C->SetLogy(1);
2908     gNPhiZt1ZYAM3->Draw("p");
2909     gAPhiZt1ZYAM3->Draw("p");
2910     gNEtaZt1ZYAM3->Draw("p");
2911     gAEtaZt1ZYAM3->Draw("p");
2912     if(DrawFit)gNPhiZt1Fit3->Draw("p");
2913     if(DrawFit)gAPhiZt1Fit3->Draw("p");
2914     if(DrawFit)gNEtaZt1Fit3->Draw("p");
2915     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2916     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2917     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2918     if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2919     if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2920     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2921     keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2922     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2923     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);
2924     cZt1ZYAM3C->SaveAs(outName);
2925     /*
2926     cZt2ZYAM1C=new TCanvas("cZt2ZYAM1C"," MidPoint",800,600);
2927     SetMargins1D(cZt2ZYAM1C);
2928     sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2929     TH2F *hZt2ZYAM1C=new TH2F("hZt2ZYAM1C",name,10,0,1,10,plotmin,plotmax);
2930     if(NoTitle)hZt2ZYAM1C->SetTitle("");
2931  
2932     hZt2ZYAM1C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2933     hZt2ZYAM1C->GetXaxis()->SetTitleColor(1);
2934     hZt2ZYAM1C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2935     SetTitles1D(hZt2ZYAM1C);
2936     hZt2ZYAM1C->Draw();
2937     cZt2ZYAM1C->SetLogy(1);
2938     gNPhiZt2ZYAM1->Draw("p");
2939     gAPhiZt2ZYAM1->Draw("p");
2940     gNEtaZt2ZYAM1->Draw("p");
2941     gAEtaZt2ZYAM1->Draw("p");
2942     //if(DrawFit)gNPhiZt2Fit1->Draw("p");
2943     //if(DrawFit)gAPhiZt2Fit1->Draw("p");
2944     //if(DrawFit)gNEtaZt2Fit1->Draw("p");
2945     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2946     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2947     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2948     // if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2949     // if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2950     keySymbol(.65,.85,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2951     keySymbol(.65,.8,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2952     // if(DrawFit)keySymbol(.65,.75,"Near #Delta#etaFit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2953     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);
2954     cZt2ZYAM1C->SaveAs(outName);
2955
2956     cZt2ZYAM2C=new TCanvas("cZt2ZYAM2C"," MidPoint",800,600);
2957     SetMargins1D(cZt2ZYAM2C);
2958     sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2959     TH2F *hZt2ZYAM2C=new TH2F("hZt2ZYAM2C",name,10,0,1,10,plotmin,plotmax);
2960     if(NoTitle)hZt2ZYAM2C->SetTitle("");
2961   
2962     hZt2ZYAM2C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2963     hZt2ZYAM2C->GetXaxis()->SetTitleColor(1);
2964     hZt2ZYAM2C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2965     SetTitles1D(hZt2ZYAM2C);
2966     hZt2ZYAM2C->Draw();
2967     cZt2ZYAM2C->SetLogy(1);
2968     gNPhiZt2ZYAM2->Draw("p");
2969     gAPhiZt2ZYAM2->Draw("p");
2970     gNEtaZt2ZYAM2->Draw("p");
2971     gAEtaZt2ZYAM2->Draw("p");
2972     //if(DrawFit)gNPhiZt2Fit2->Draw("p");
2973     //if(DrawFit)gAPhiZt2Fit2->Draw("p");
2974     // if(DrawFit)gNEtaZt2Fit2->Draw("p");
2975     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
2976     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
2977     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
2978     // if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
2979     //  if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
2980     keySymbol(.65,.85,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
2981     keySymbol(.65,.8,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
2982     // if(DrawFit)keySymbol(.65,.75,"Near #Delta#etaFit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
2983     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);
2984     cZt2ZYAM2C->SaveAs(outName);
2985
2986     cZt2ZYAM3C=new TCanvas("cZt2ZYAM3C"," MidPoint",800,600);
2987     SetMargins1D(cZt2ZYAM3C);
2988     sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
2989     TH2F *hZt2ZYAM3C=new TH2F("hZt2ZYAM3C",name,10,0,1,10,plotmin,plotmax);
2990     if(NoTitle)hZt2ZYAM3C->SetTitle("");
2991     hZt2ZYAM3C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
2992     hZt2ZYAM3C->GetXaxis()->SetTitleColor(1);
2993     hZt2ZYAM3C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
2994   
2995     SetTitles1D(hZt2ZYAM3C);
2996     hZt2ZYAM3C->Draw();
2997     cZt2ZYAM3C->SetLogy(1);
2998     gNPhiZt2ZYAM3->Draw("p");
2999     gAPhiZt2ZYAM3->Draw("p");
3000     gNEtaZt2ZYAM3->Draw("p");
3001     gAEtaZt2ZYAM3->Draw("p");
3002     // if(DrawFit)gNPhiZt2Fit3->Draw("p");
3003     // if(DrawFit)gAPhiZt2Fit3->Draw("p");
3004     //  if(DrawFit)gNEtaZt2Fit3->Draw("p");
3005     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
3006     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3007     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3008     // if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3009     //  if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3010     keySymbol(.65,.85,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
3011     keySymbol(.65,.8,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
3012     // if(DrawFit)keySymbol(.65,.75,"Near #Delta#etaFit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3013     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);
3014     cZt2ZYAM3C->SaveAs(outName);
3015     */
3016
3017     cWidth1=new TCanvas("cWidth1","Width MidPoint",800,600);
3018     SetMargins1D(cWidth1);
3019     sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
3020     TH2F *hWidth1=new TH2F("hWidth1",name,10,0,TPt1,10,plotminW,plotmaxW);
3021     if(NoTitle)hWidth1->SetTitle("");
3022     hWidth1->GetXaxis()->SetTitle("p_{T}^{Assoc} (GeV/c) ");
3023     hWidth1->GetXaxis()->SetTitleColor(1);
3024     hWidth1->GetYaxis()->SetTitle("#sigma (radians)   ");
3025     SetTitles1D(hWidth1);
3026     hWidth1->Draw();
3027     gNPhiWidth1->Draw("p");
3028     gAPhiWidth1->Draw("p");
3029     gNEtaWidth1->Draw("p");
3030     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3031     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3032     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3033     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);
3034     cWidth1->SaveAs(outName);
3035
3036     cWidth2=new TCanvas("cWidth2","Width MidPoint",800,600);
3037     SetMargins1D(cWidth2);
3038     sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
3039     TH2F *hWidth2=new TH2F("hWidth2",name,10,0,TPt1,10,plotminW,plotmaxW);
3040     if(NoTitle)hWidth2->SetTitle("");
3041     hWidth2->GetXaxis()->SetTitle("p_{T}^{Assoc} (GeV/c) ");
3042     hWidth2->GetXaxis()->SetTitleColor(1);
3043     hWidth2->GetYaxis()->SetTitle("#sigma (radians)   ");
3044     SetTitles1D(hWidth2);
3045     hWidth2->Draw();
3046     gNPhiWidth2->Draw("p");
3047     gAPhiWidth2->Draw("p");
3048     gNEtaWidth2->Draw("p");
3049     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3050     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3051     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3052     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);
3053     cWidth2->SaveAs(outName);
3054
3055     cWidth3=new TCanvas("cWidth3","Width MidPoint",800,600);
3056     SetMargins1D(cWidth3);
3057     sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
3058     TH2F *hWidth3=new TH2F("hWidth3",name,10,0,TPt1,10,plotminW,plotmaxW);
3059     if(NoTitle)hWidth3->SetTitle("");
3060     hWidth3->GetXaxis()->SetTitle("p_{T}^{Assoc} (GeV/c) ");
3061     hWidth3->GetXaxis()->SetTitleColor(1);
3062     hWidth3->GetYaxis()->SetTitle("#sigma (radians)   ");
3063     SetTitles1D(hWidth3);
3064     hWidth3->Draw();
3065     gNPhiWidth3->Draw("p");
3066     gAPhiWidth3->Draw("p");
3067     gNEtaWidth3->Draw("p");
3068     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3069     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3070     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3071     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);
3072     cWidth3->SaveAs(outName);
3073
3074   }
3075
3076   if(APtTPtMult==1){
3077     if(HorizontalErrors==0){
3078       for(int mloop=0;mloop<nMainLoop;mloop++){
3079         NXPhi[1][mloop]=0;
3080         NXPhi[3][mloop]=0;
3081         NXPhi[5][mloop]=0;
3082         NXPhi[7][mloop]=0;
3083         NXPhi[9][mloop]=0;
3084         NXPhi[11][mloop]=0;
3085         NXPhi[13][mloop]=0;
3086         NXPhi[15][mloop]=0;
3087         NXPhi[17][mloop]=0;
3088         AXPhi[1][mloop]=0;
3089         AXPhi[3][mloop]=0;
3090         AXPhi[5][mloop]=0;
3091         AXPhi[7][mloop]=0;
3092         AXPhi[9][mloop]=0;
3093         AXPhi[11][mloop]=0;
3094         AXPhi[13][mloop]=0;
3095         AXPhi[15][mloop]=0;
3096         AXPhi[17][mloop]=0;
3097         NXPhiFit[1][mloop]=0;
3098         NXPhiFit[3][mloop]=0;
3099         NXPhiFit[5][mloop]=0;
3100         NXPhiFit[7][mloop]=0;
3101         NXPhiFit[9][mloop]=0;
3102         NXPhiFit[11][mloop]=0;
3103         NXPhiFit[13][mloop]=0;
3104         NXPhiFit[15][mloop]=0;
3105         NXPhiFit[17][mloop]=0;
3106         AXPhiFit[1][mloop]=0;
3107         AXPhiFit[3][mloop]=0;
3108         AXPhiFit[5][mloop]=0;
3109         AXPhiFit[7][mloop]=0;
3110         AXPhiFit[9][mloop]=0;
3111         AXPhiFit[11][mloop]=0;
3112         AXPhiFit[13][mloop]=0;
3113         AXPhiFit[15][mloop]=0;
3114         AXPhiFit[17][mloop]=0;
3115         NXEta[1][mloop]=0;
3116         NXEta[3][mloop]=0;
3117         NXEta[5][mloop]=0;
3118         NXEta[7][mloop]=0;
3119         NXEta[9][mloop]=0;
3120         NXEta[11][mloop]=0;
3121         NXEta[13][mloop]=0;
3122         NXEta[15][mloop]=0;
3123         NXEta[17][mloop]=0;
3124         AXEta[1][mloop]=0;
3125         AXEta[3][mloop]=0;
3126         AXEta[5][mloop]=0;
3127         AXEta[7][mloop]=0;
3128         AXEta[9][mloop]=0;
3129         AXEta[11][mloop]=0;
3130         AXEta[13][mloop]=0;
3131         AXEta[15][mloop]=0;
3132         AXEta[17][mloop]=0;
3133         NXEtaFit[1][mloop]=0;
3134         NXEtaFit[3][mloop]=0;
3135         NXEtaFit[5][mloop]=0;
3136         NXEtaFit[7][mloop]=0;
3137         NXEtaFit[9][mloop]=0;
3138         NXEtaFit[11][mloop]=0;
3139         NXEtaFit[13][mloop]=0;
3140         NXEtaFit[15][mloop]=0;
3141         NXEtaFit[17][mloop]=0;
3142         AXEtaFit[1][mloop]=0;
3143         AXEtaFit[3][mloop]=0;
3144         AXEtaFit[5][mloop]=0;
3145         AXEtaFit[7][mloop]=0;
3146         AXEtaFit[9][mloop]=0;
3147         AXEtaFit[11][mloop]=0;
3148         AXEtaFit[13][mloop]=0;
3149         AXEtaFit[15][mloop]=0;
3150         AXEtaFit[17][mloop]=0;
3151       }
3152     }
3153     gNYieldPhi=new TGraphErrors(nMainLoop,NXPhi[0],NYieldPhiZYAM[0],NXPhi[1],NYieldPhiZYAM[1]);
3154     gAYieldPhi=new TGraphErrors(nMainLoop,NXPhi[0],AYieldPhiZYAM[0],NXPhi[1],AYieldPhiZYAM[1]);
3155     gMYieldPhi=new TGraphErrors(nMainLoop,NXPhi[0],MYieldPhi[0],NXPhi[1],MYieldPhi[1]);
3156     gNYieldPhiPt=new TGraphErrors(nMainLoop,NXPhi[0],NYieldPhiZYAM[2],NXPhi[1],NYieldPhiZYAM[3]);
3157     gAYieldPhiPt=new TGraphErrors(nMainLoop,NXPhi[0],AYieldPhiZYAM[2],NXPhi[1],AYieldPhiZYAM[3]);
3158     gMYieldPhiPt=new TGraphErrors(nMainLoop,NXPhi[0],MYieldPhi[2],NXPhi[1],MYieldPhi[3]);
3159
3160     gNYieldPhi2=new TGraphErrors(nMainLoop,NXPhi[2],NYieldPhiZYAM[0],NXPhi[3],NYieldPhiZYAM[1]);
3161     gAYieldPhi2=new TGraphErrors(nMainLoop,NXPhi[2],AYieldPhiZYAM[0],NXPhi[3],AYieldPhiZYAM[1]);
3162     gMYieldPhi2=new TGraphErrors(nMainLoop,NXPhi[2],MYieldPhi[0],NXPhi[3],MYieldPhi[1]);
3163     gNYieldPhiPt2=new TGraphErrors(nMainLoop,NXPhi[2],NYieldPhiZYAM[2],NXPhi[3],NYieldPhiZYAM[3]);
3164     gAYieldPhiPt2=new TGraphErrors(nMainLoop,NXPhi[2],AYieldPhiZYAM[2],NXPhi[3],AYieldPhiZYAM[3]);
3165     gMYieldPhiPt2=new TGraphErrors(nMainLoop,NXPhi[2],MYieldPhi[2],NXPhi[3],MYieldPhi[3]);
3166
3167     gNYieldPhi3=new TGraphErrors(nMainLoop,NXPhi[4],NYieldPhiZYAM[0],NXPhi[5],NYieldPhiZYAM[1]);
3168     gAYieldPhi3=new TGraphErrors(nMainLoop,NXPhi[4],AYieldPhiZYAM[0],NXPhi[5],AYieldPhiZYAM[1]);
3169     gMYieldPhi3=new TGraphErrors(nMainLoop,NXPhi[4],MYieldPhi[0],NXPhi[5],MYieldPhi[1]);
3170     gNYieldPhiPt3=new TGraphErrors(nMainLoop,NXPhi[4],NYieldPhiZYAM[2],NXPhi[5],NYieldPhiZYAM[3]);
3171     gAYieldPhiPt3=new TGraphErrors(nMainLoop,NXPhi[4],AYieldPhiZYAM[2],NXPhi[5],AYieldPhiZYAM[3]);
3172     gMYieldPhiPt3=new TGraphErrors(nMainLoop,NXPhi[4],MYieldPhi[2],NXPhi[5],MYieldPhi[3]);
3173
3174     gNYieldPhiFit=new TGraphErrors(nMainLoop,NXPhiFit[0],NYieldPhiFit[0],NXPhiFit[1],NYieldPhiFit[1]);
3175     gAYieldPhiFit=new TGraphErrors(nMainLoop,NXPhiFit[0],AYieldPhiFit[0],NXPhiFit[1],AYieldPhiFit[1]);
3176     gMYieldPhiFit=new TGraphErrors(nMainLoop,NXPhiFit[0],MYieldPhiFit[0],NXPhiFit[1],MYieldPhiFit[1]);
3177     gNYieldPhiFitPt=new TGraphErrors(nMainLoop,NXPhiFit[0],NYieldPhiFit[2],NXPhiFit[1],NYieldPhiFit[3]);
3178     gAYieldPhiFitPt=new TGraphErrors(nMainLoop,NXPhiFit[0],AYieldPhiFit[2],NXPhiFit[1],AYieldPhiFit[3]);
3179     gMYieldPhiFitPt=new TGraphErrors(nMainLoop,NXPhiFit[0],MYieldPhiFit[2],NXPhiFit[1],MYieldPhiFit[3]);
3180
3181     gNYieldPhiFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],NYieldPhiFit[0],NXPhiFit[3],NYieldPhiFit[1]);
3182     gAYieldPhiFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],AYieldPhiFit[0],NXPhiFit[3],AYieldPhiFit[1]);
3183     gMYieldPhiFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],MYieldPhiFit[0],NXPhiFit[3],MYieldPhiFit[1]);
3184     gNYieldPhiFitPt2=new TGraphErrors(nMainLoop,NXPhiFit[2],NYieldPhiFit[2],NXPhiFit[3],NYieldPhiFit[3]);
3185     gAYieldPhiFitPt2=new TGraphErrors(nMainLoop,NXPhiFit[2],AYieldPhiFit[2],NXPhiFit[3],AYieldPhiFit[3]);
3186     gMYieldPhiFitPt2=new TGraphErrors(nMainLoop,NXPhiFit[2],MYieldPhiFit[2],NXPhiFit[3],MYieldPhiFit[3]);
3187
3188     gNYieldPhiFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],NYieldPhiFit[0],NXPhiFit[5],NYieldPhiFit[1]);
3189     gAYieldPhiFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],AYieldPhiFit[0],NXPhiFit[5],AYieldPhiFit[1]);
3190     gMYieldPhiFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],MYieldPhiFit[0],NXPhiFit[5],MYieldPhiFit[1]);
3191     gNYieldPhiFitPt3=new TGraphErrors(nMainLoop,NXPhiFit[4],NYieldPhiFit[2],NXPhiFit[5],NYieldPhiFit[3]);
3192     gAYieldPhiFitPt3=new TGraphErrors(nMainLoop,NXPhiFit[4],AYieldPhiFit[2],NXPhiFit[5],AYieldPhiFit[3]);
3193     gMYieldPhiFitPt3=new TGraphErrors(nMainLoop,NXPhiFit[4],MYieldPhiFit[2],NXPhiFit[5],MYieldPhiFit[3]);
3194    
3195     gNPhiWidth1=new TGraphErrors(nMainLoop,NXPhiFit[0],NWidthPhi[0],NXPhiFit[1],NWidthPhi[1]);
3196     gNPhiWidth2=new TGraphErrors(nMainLoop,NXPhiFit[2],NWidthPhi[0],NXPhiFit[3],NWidthPhi[1]);
3197     gNPhiWidth3=new TGraphErrors(nMainLoop,NXPhiFit[4],NWidthPhi[0],NXPhiFit[5],NWidthPhi[1]);
3198     gAPhiWidth1=new TGraphErrors(nMainLoop,AXPhiFit[0],AWidthPhi[0],AXPhiFit[1],AWidthPhi[1]);
3199     gAPhiWidth2=new TGraphErrors(nMainLoop,AXPhiFit[2],AWidthPhi[0],AXPhiFit[3],AWidthPhi[1]);
3200     gAPhiWidth3=new TGraphErrors(nMainLoop,AXPhiFit[4],AWidthPhi[0],AXPhiFit[5],AWidthPhi[1]);
3201
3202     gNPhiJt1=new TGraphErrors(nMainLoop,NXPhiFit[0],NJtPhi[0],NXPhiFit[1],NJtPhi[1]);
3203     gNPhiJt2=new TGraphErrors(nMainLoop,NXPhiFit[2],NJtPhi[0],NXPhiFit[3],NJtPhi[1]);
3204     gNPhiJt3=new TGraphErrors(nMainLoop,NXPhiFit[4],NJtPhi[0],NXPhiFit[5],NJtPhi[1]);
3205
3206     gNYieldEta=new TGraphErrors(nMainLoop,NXEta[0],NYieldEtaZYAM[0],NXEta[1],NYieldEtaZYAM[1]);
3207     gAYieldEta=new TGraphErrors(nMainLoop,NXEta[0],AYieldEtaZYAM[0],NXEta[1],AYieldEtaZYAM[1]);
3208     gNYieldEtaPt=new TGraphErrors(nMainLoop,NXEta[0],NYieldEtaZYAM[2],NXEta[1],NYieldEtaZYAM[3]);
3209     gAYieldEtaPt=new TGraphErrors(nMainLoop,NXEta[0],AYieldEtaZYAM[2],NXEta[1],AYieldEtaZYAM[3]);
3210   
3211     gNYieldEta2=new TGraphErrors(nMainLoop,NXEta[2],NYieldEtaZYAM[0],NXEta[3],NYieldEtaZYAM[1]);
3212     gAYieldEta2=new TGraphErrors(nMainLoop,NXEta[2],AYieldEtaZYAM[0],NXEta[3],AYieldEtaZYAM[1]);
3213     gNYieldEtaPt2=new TGraphErrors(nMainLoop,NXEta[2],NYieldEtaZYAM[2],NXEta[3],NYieldEtaZYAM[3]);
3214     gAYieldEtaPt2=new TGraphErrors(nMainLoop,NXEta[2],AYieldEtaZYAM[2],NXEta[3],AYieldEtaZYAM[3]);
3215
3216     gNYieldEta3=new TGraphErrors(nMainLoop,NXEta[4],NYieldEtaZYAM[0],NXEta[5],NYieldEtaZYAM[1]);
3217     gAYieldEta3=new TGraphErrors(nMainLoop,NXEta[4],AYieldEtaZYAM[0],NXEta[5],AYieldEtaZYAM[1]);
3218     gNYieldEtaPt3=new TGraphErrors(nMainLoop,NXEta[4],NYieldEtaZYAM[2],NXEta[5],NYieldEtaZYAM[3]);
3219     gAYieldEtaPt3=new TGraphErrors(nMainLoop,NXEta[4],AYieldEtaZYAM[2],NXEta[5],AYieldEtaZYAM[3]);
3220  
3221     gNYieldEtaFit=new TGraphErrors(nMainLoop,NXEtaFit[0],NYieldEtaFit[0],NXEtaFit[1],NYieldEtaFit[1]);
3222     // gAYieldEtaFit=new TGraphErrors(nMainLoop,NXEtaFit[0],AYieldEtaFit[0],NXEtaFit[1],AYieldEtaFit[1]);
3223     gNYieldEtaFitPt=new TGraphErrors(nMainLoop,NXEtaFit[0],NYieldEtaFit[2],NXEtaFit[1],NYieldEtaFit[3]);
3224     // gAYieldEtaFitPt=new TGraphErrors(nMainLoop,NXEtaFit[0],AYieldEtaFit[2],NXEtaFit[1],AYieldEtaFit[3]);
3225
3226     gNYieldEtaFit2=new TGraphErrors(nMainLoop,NXEtaFit[2],NYieldEtaFit[0],NXEtaFit[3],NYieldEtaFit[1]);
3227     //gAYieldEtaFit2=new TGraphErrors(nMainLoop,NXEtaFit[2],AYieldEtaFit[0],NXEtaFit[3],AYieldEtaFit[1]);
3228     gNYieldEtaFitPt2=new TGraphErrors(nMainLoop,NXEtaFit[2],NYieldEtaFit[2],NXEtaFit[3],NYieldEtaFit[3]);
3229     // gAYieldEtaFitPt2=new TGraphErrors(nMainLoop,NXEtaFit[2],AYieldEtaFit[2],NXEtaFit[3],AYieldEtaFit[3]);
3230
3231     gNYieldEtaFit3=new TGraphErrors(nMainLoop,NXEtaFit[4],NYieldEtaFit[0],NXEtaFit[5],NYieldEtaFit[1]);
3232     // gAYieldEtaFit3=new TGraphErrors(nMainLoop,NXEtaFit[4],AYieldEtaFit[0],NXEtaFit[5],AYieldEtaFit[1]);
3233     gNYieldEtaFitPt3=new TGraphErrors(nMainLoop,NXEtaFit[4],NYieldEtaFit[2],NXEtaFit[5],NYieldEtaFit[3]);
3234     // gAYieldEtaFitPt3=new TGraphErrors(nMainLoop,NXEtaFit[4],AYieldEtaFit[2],NXEtaFit[5],AYieldEtaFit[3]);
3235
3236     gNEtaWidth1=new TGraphErrors(nMainLoop,NXPhiFit[0],NWidthEta[0],NXPhiFit[1],NWidthEta[1]);
3237     gNEtaWidth2=new TGraphErrors(nMainLoop,NXPhiFit[2],NWidthEta[0],NXPhiFit[3],NWidthEta[1]);
3238     gNEtaWidth3=new TGraphErrors(nMainLoop,NXPhiFit[4],NWidthEta[0],NXPhiFit[5],NWidthEta[1]);
3239
3240     gNEtaJt1=new TGraphErrors(nMainLoop,NXEtaFit[0],NJtEta[0],NXEtaFit[1],NJtEta[1]);
3241     gNEtaJt2=new TGraphErrors(nMainLoop,NXEtaFit[2],NJtEta[0],NXEtaFit[3],NJtEta[1]);
3242     gNEtaJt3=new TGraphErrors(nMainLoop,NXEtaFit[4],NJtEta[0],NXEtaFit[5],NJtEta[1]);
3243
3244     gNAvePhi1=new TGraphErrors(nMainLoop,NXPhi[0],NAvePhi[0],NXPhi[1],NAvePhi[1]);
3245     gNAvePhi2=new TGraphErrors(nMainLoop,NXPhi[2],NAvePhi[0],NXPhi[3],NAvePhi[1]);
3246     gNAvePhi3=new TGraphErrors(nMainLoop,NXPhi[4],NAvePhi[0],NXPhi[5],NAvePhi[1]);
3247
3248     gAAvePhi1=new TGraphErrors(nMainLoop,NXPhi[0],AAvePhi[0],NXPhi[1],AAvePhi[1]);
3249     gAAvePhi2=new TGraphErrors(nMainLoop,NXPhi[2],AAvePhi[0],NXPhi[3],AAvePhi[1]);
3250     gAAvePhi3=new TGraphErrors(nMainLoop,NXPhi[4],AAvePhi[0],NXPhi[5],AAvePhi[1]);
3251
3252     gMAvePhi1=new TGraphErrors(nMainLoop,NXPhi[0],MAvePhi[0],NXPhi[1],MAvePhi[1]);
3253     gMAvePhi2=new TGraphErrors(nMainLoop,NXPhi[2],MAvePhi[0],NXPhi[3],MAvePhi[1]);
3254     gMAvePhi3=new TGraphErrors(nMainLoop,NXPhi[4],MAvePhi[0],NXPhi[5],MAvePhi[1]);
3255
3256     gNAveEta1=new TGraphErrors(nMainLoop,NXEta[0],NAveEta[0],NXEta[1],NAveEta[1]);
3257     gNAveEta2=new TGraphErrors(nMainLoop,NXEta[2],NAveEta[0],NXEta[3],NAveEta[1]);
3258     gNAveEta3=new TGraphErrors(nMainLoop,NXEta[4],NAveEta[0],NXEta[5],NAveEta[1]);
3259
3260     gAAveEta1=new TGraphErrors(nMainLoop,NXEta[0],AAveEta[0],NXEta[1],AAveEta[1]);
3261     gAAveEta2=new TGraphErrors(nMainLoop,NXEta[2],AAveEta[0],NXEta[3],AAveEta[1]);
3262     gAAveEta3=new TGraphErrors(nMainLoop,NXEta[4],AAveEta[0],NXEta[5],AAveEta[1]);
3263
3264     gNAvePhiFit1=new TGraphErrors(nMainLoop,NXPhi[0],NAvePhiFit[0],NXPhi[1],NAvePhiFit[1]);
3265     gNAvePhiFit2=new TGraphErrors(nMainLoop,NXPhi[2],NAvePhiFit[0],NXPhi[3],NAvePhiFit[1]);
3266     gNAvePhiFit3=new TGraphErrors(nMainLoop,NXPhi[4],NAvePhiFit[0],NXPhi[5],NAvePhiFit[1]);
3267
3268     gAAvePhiFit1=new TGraphErrors(nMainLoop,NXPhi[0],AAvePhiFit[0],NXPhi[1],AAvePhiFit[1]);
3269     gAAvePhiFit2=new TGraphErrors(nMainLoop,NXPhi[2],AAvePhiFit[0],NXPhi[3],AAvePhiFit[1]);
3270     gAAvePhiFit3=new TGraphErrors(nMainLoop,NXPhi[4],AAvePhiFit[0],NXPhi[5],AAvePhiFit[1]);
3271
3272     gMAvePhiFit1=new TGraphErrors(nMainLoop,NXPhi[0],MAvePhiFit[0],NXPhi[1],MAvePhiFit[1]);
3273     gMAvePhiFit2=new TGraphErrors(nMainLoop,NXPhi[2],MAvePhiFit[0],NXPhi[3],MAvePhiFit[1]);
3274     gMAvePhiFit3=new TGraphErrors(nMainLoop,NXPhi[4],MAvePhiFit[0],NXPhi[5],MAvePhiFit[1]);
3275
3276     gNAveEtaFit1=new TGraphErrors(nMainLoop,NXEta[0],NAveEtaFit[0],NXEta[1],NAveEtaFit[1]);
3277     gNAveEtaFit2=new TGraphErrors(nMainLoop,NXEta[2],NAveEtaFit[0],NXEta[3],NAveEtaFit[1]);
3278     gNAveEtaFit3=new TGraphErrors(nMainLoop,NXEta[4],NAveEtaFit[0],NXEta[5],NAveEtaFit[1]);
3279    
3280     gNYieldPhi->SetMarkerStyle(MarkerNearPhi);
3281     gAYieldPhi->SetMarkerStyle(MarkerAwayPhi);
3282     gMYieldPhi->SetMarkerStyle(MarkerMin);
3283     gNYieldPhiPt->SetMarkerStyle(MarkerNearPhi);
3284     gAYieldPhiPt->SetMarkerStyle(MarkerAwayPhi);
3285     gMYieldPhiPt->SetMarkerStyle(MarkerMin);
3286     gNYieldPhi2->SetMarkerStyle(MarkerNearPhi);
3287     gAYieldPhi2->SetMarkerStyle(MarkerAwayPhi);
3288     gMYieldPhi2->SetMarkerStyle(MarkerMin);
3289     gNYieldPhiPt2->SetMarkerStyle(MarkerNearPhi);
3290     gAYieldPhiPt2->SetMarkerStyle(MarkerAwayPhi);
3291     gMYieldPhiPt2->SetMarkerStyle(MarkerMin);
3292     gNYieldPhi3->SetMarkerStyle(MarkerNearPhi);
3293     gAYieldPhi3->SetMarkerStyle(MarkerAwayPhi);
3294     gMYieldPhi3->SetMarkerStyle(MarkerMin);
3295     gNYieldPhiPt3->SetMarkerStyle(MarkerNearPhi);
3296     gAYieldPhiPt3->SetMarkerStyle(MarkerAwayPhi);
3297     gMYieldPhiPt3->SetMarkerStyle(MarkerMin);
3298     gNYieldPhi->SetMarkerColor(ColorNearPhi);
3299     gAYieldPhi->SetMarkerColor(ColorAwayPhi);
3300     gMYieldPhi->SetMarkerColor(ColorMin);
3301     gNYieldPhi->SetLineColor(ColorNearPhi);
3302     gAYieldPhi->SetLineColor(ColorAwayPhi);
3303     gMYieldPhi->SetLineColor(ColorMin);
3304     gNYieldPhiPt->SetMarkerColor(ColorNearPhi);
3305     gAYieldPhiPt->SetMarkerColor(ColorAwayPhi);
3306     gMYieldPhiPt->SetMarkerColor(ColorMin);
3307     gNYieldPhiPt->SetLineColor(ColorNearPhi);
3308     gAYieldPhiPt->SetLineColor(ColorAwayPhi);
3309     gMYieldPhiPt->SetLineColor(ColorMin);
3310     gNYieldPhi2->SetMarkerColor(ColorNearPhi);
3311     gAYieldPhi2->SetMarkerColor(ColorAwayPhi);
3312     gMYieldPhi2->SetMarkerColor(ColorMin);
3313     gNYieldPhi2->SetLineColor(ColorNearPhi);
3314     gAYieldPhi2->SetLineColor(ColorAwayPhi);
3315     gMYieldPhi2->SetLineColor(ColorMin);
3316     gNYieldPhiPt2->SetMarkerColor(ColorNearPhi);
3317     gAYieldPhiPt2->SetMarkerColor(ColorAwayPhi);
3318     gMYieldPhiPt2->SetMarkerColor(ColorMin);
3319     gNYieldPhiPt2->SetLineColor(ColorNearPhi);
3320     gAYieldPhiPt2->SetLineColor(ColorAwayPhi);
3321     gMYieldPhiPt2->SetLineColor(ColorMin);
3322     gNYieldPhi3->SetMarkerColor(ColorNearPhi);
3323     gAYieldPhi3->SetMarkerColor(ColorAwayPhi);
3324     gMYieldPhi3->SetMarkerColor(ColorMin);
3325     gNYieldPhi3->SetLineColor(ColorNearPhi);
3326     gAYieldPhi3->SetLineColor(ColorAwayPhi);
3327     gMYieldPhi3->SetLineColor(ColorMin);
3328     gNYieldPhiPt3->SetMarkerColor(ColorNearPhi);
3329     gAYieldPhiPt3->SetMarkerColor(ColorAwayPhi);
3330     gMYieldPhiPt3->SetMarkerColor(ColorMin);
3331     gNYieldPhiPt3->SetLineColor(ColorNearPhi);
3332     gAYieldPhiPt3->SetLineColor(ColorAwayPhi);
3333     gMYieldPhiPt3->SetLineColor(ColorMin);
3334     gNYieldPhi->SetMarkerSize(MarkerSize);
3335     gAYieldPhi->SetMarkerSize(MarkerSize);
3336     gMYieldPhi->SetMarkerSize(MarkerSize);
3337     gNYieldPhiPt->SetMarkerSize(MarkerSize);
3338     gAYieldPhiPt->SetMarkerSize(MarkerSize);
3339     gMYieldPhiPt->SetMarkerSize(MarkerSize);
3340     gNYieldPhi2->SetMarkerSize(MarkerSize);
3341     gAYieldPhi2->SetMarkerSize(MarkerSize);
3342     gMYieldPhi2->SetMarkerSize(MarkerSize);
3343     gNYieldPhiPt2->SetMarkerSize(MarkerSize);
3344     gAYieldPhiPt2->SetMarkerSize(MarkerSize);
3345     gMYieldPhiPt2->SetMarkerSize(MarkerSize);
3346     gNYieldPhi3->SetMarkerSize(MarkerSize);
3347     gAYieldPhi3->SetMarkerSize(MarkerSize);
3348     gMYieldPhi3->SetMarkerSize(MarkerSize);
3349     gNYieldPhiPt3->SetMarkerSize(MarkerSize);
3350     gAYieldPhiPt3->SetMarkerSize(MarkerSize);
3351     gNYieldPhiPt3->SetMarkerSize(MarkerSize);
3352
3353     gNYieldPhiFit->SetMarkerStyle(MarkerNearPhiFit);
3354     gNYieldPhiFit->SetMarkerSize(MarkerSize);
3355     gNYieldPhiFit->SetMarkerColor(ColorNearPhiFit);
3356     gNYieldPhiFit->SetLineColor(ColorNearPhiFit);
3357     gNYieldPhiFit2->SetMarkerStyle(MarkerNearPhiFit);
3358     gNYieldPhiFit2->SetMarkerSize(MarkerSize);
3359     gNYieldPhiFit2->SetMarkerColor(ColorNearPhiFit);
3360     gNYieldPhiFit2->SetLineColor(ColorNearPhiFit);
3361     gNYieldPhiFit3->SetMarkerStyle(MarkerNearPhiFit);
3362     gNYieldPhiFit3->SetMarkerSize(MarkerSize);
3363     gNYieldPhiFit3->SetMarkerColor(ColorNearPhiFit);
3364     gNYieldPhiFit3->SetLineColor(ColorNearPhiFit);
3365
3366     gAYieldPhiFit->SetMarkerStyle(MarkerAwayPhiFit);
3367     gAYieldPhiFit->SetMarkerSize(MarkerSize);
3368     gAYieldPhiFit->SetMarkerColor(ColorAwayPhiFit);
3369     gAYieldPhiFit->SetLineColor(ColorAwayPhiFit);
3370     gAYieldPhiFit2->SetMarkerStyle(MarkerAwayPhiFit);
3371     gAYieldPhiFit2->SetMarkerSize(MarkerSize);
3372     gAYieldPhiFit2->SetMarkerColor(ColorAwayPhiFit);
3373     gAYieldPhiFit2->SetLineColor(ColorAwayPhiFit);
3374     gAYieldPhiFit3->SetMarkerStyle(MarkerAwayPhiFit);
3375     gAYieldPhiFit3->SetMarkerSize(MarkerSize);
3376     gAYieldPhiFit3->SetMarkerColor(ColorAwayPhiFit);
3377     gAYieldPhiFit3->SetLineColor(ColorAwayPhiFit);
3378
3379     gMYieldPhiFit->SetMarkerStyle(MarkerMinFit);
3380     gMYieldPhiFit->SetMarkerSize(MarkerSize);
3381     gMYieldPhiFit->SetMarkerColor(ColorMinFit);
3382     gMYieldPhiFit->SetLineColor(ColorMinFit);
3383     gMYieldPhiFit2->SetMarkerStyle(MarkerMinFit);
3384     gMYieldPhiFit2->SetMarkerSize(MarkerSize);
3385     gMYieldPhiFit2->SetMarkerColor(ColorMinFit);
3386     gMYieldPhiFit2->SetLineColor(ColorMinFit);
3387     gMYieldPhiFit3->SetMarkerStyle(MarkerMinFit);
3388     gMYieldPhiFit3->SetMarkerSize(MarkerSize);
3389     gMYieldPhiFit3->SetMarkerColor(ColorMinFit);
3390     gMYieldPhiFit3->SetLineColor(ColorMinFit);
3391
3392     gNYieldPhiFitPt->SetMarkerStyle(MarkerNearPhiFit);
3393     gNYieldPhiFitPt->SetMarkerSize(MarkerSize);
3394     gNYieldPhiFitPt->SetMarkerColor(ColorNearPhiFit);
3395     gNYieldPhiFitPt->SetLineColor(ColorNearPhiFit);
3396     gNYieldPhiFitPt2->SetMarkerStyle(MarkerNearPhiFit);
3397     gNYieldPhiFitPt2->SetMarkerSize(MarkerSize);
3398     gNYieldPhiFitPt2->SetMarkerColor(ColorNearPhiFit);
3399     gNYieldPhiFitPt2->SetLineColor(ColorNearPhiFit);
3400     gNYieldPhiFitPt3->SetMarkerStyle(MarkerNearPhiFit);
3401     gNYieldPhiFitPt3->SetMarkerSize(MarkerSize);
3402     gNYieldPhiFitPt3->SetMarkerColor(ColorNearPhiFit);
3403     gNYieldPhiFitPt3->SetLineColor(ColorNearPhiFit);
3404
3405     gAYieldPhiFitPt->SetMarkerStyle(MarkerAwayPhiFit);
3406     gAYieldPhiFitPt->SetMarkerSize(MarkerSize);
3407     gAYieldPhiFitPt->SetMarkerColor(ColorAwayPhiFit);
3408     gAYieldPhiFitPt->SetLineColor(ColorAwayPhiFit);
3409     gAYieldPhiFitPt2->SetMarkerStyle(MarkerAwayPhiFit);
3410     gAYieldPhiFitPt2->SetMarkerSize(MarkerSize);
3411     gAYieldPhiFitPt2->SetMarkerColor(ColorAwayPhiFit);
3412     gAYieldPhiFitPt2->SetLineColor(ColorAwayPhiFit);
3413     gAYieldPhiFitPt3->SetMarkerStyle(MarkerAwayPhiFit);
3414     gAYieldPhiFitPt3->SetMarkerSize(MarkerSize);
3415     gAYieldPhiFitPt3->SetMarkerColor(ColorAwayPhiFit);
3416     gAYieldPhiFitPt3->SetLineColor(ColorAwayPhiFit);
3417
3418     gMYieldPhiFitPt->SetMarkerStyle(MarkerMinFit);
3419     gMYieldPhiFitPt->SetMarkerSize(MarkerSize);
3420     gMYieldPhiFitPt->SetMarkerColor(ColorMinFit);
3421     gMYieldPhiFitPt->SetLineColor(ColorMinFit);
3422     gMYieldPhiFitPt2->SetMarkerStyle(MarkerMinFit);
3423     gMYieldPhiFitPt2->SetMarkerSize(MarkerSize);
3424     gMYieldPhiFitPt2->SetMarkerColor(ColorMinFit);
3425     gMYieldPhiFitPt2->SetLineColor(ColorMinFit);
3426     gMYieldPhiFitPt3->SetMarkerStyle(MarkerMinFit);
3427     gMYieldPhiFitPt3->SetMarkerSize(MarkerSize);
3428     gMYieldPhiFitPt3->SetMarkerColor(ColorMinFit);
3429     gMYieldPhiFitPt3->SetLineColor(ColorMinFit);
3430
3431     gNPhiWidth1->SetMarkerStyle(MarkerNearPhiFit);
3432     gNPhiWidth1->SetMarkerSize(MarkerSize);
3433     gNPhiWidth1->SetMarkerColor(ColorNearPhiFit);
3434     gNPhiWidth1->SetLineColor(ColorNearPhiFit);
3435     gNPhiWidth2->SetMarkerStyle(MarkerNearPhiFit);
3436     gNPhiWidth2->SetMarkerSize(MarkerSize);
3437     gNPhiWidth2->SetMarkerColor(ColorNearPhiFit);
3438     gNPhiWidth2->SetLineColor(ColorNearPhiFit);
3439     gNPhiWidth3->SetMarkerStyle(MarkerNearPhiFit);
3440     gNPhiWidth3->SetMarkerSize(MarkerSize);
3441     gNPhiWidth3->SetMarkerColor(ColorNearPhiFit);
3442     gNPhiWidth3->SetLineColor(ColorNearPhiFit);
3443
3444     gAPhiWidth1->SetMarkerStyle(MarkerAwayPhiFit);
3445     gAPhiWidth1->SetMarkerSize(MarkerSize);
3446     gAPhiWidth1->SetMarkerColor(ColorAwayPhiFit);
3447     gAPhiWidth1->SetLineColor(ColorAwayPhiFit);
3448     gAPhiWidth2->SetMarkerStyle(MarkerAwayPhiFit);
3449     gAPhiWidth2->SetMarkerSize(MarkerSize);
3450     gAPhiWidth2->SetMarkerColor(ColorAwayPhiFit);
3451     gAPhiWidth2->SetLineColor(ColorAwayPhiFit);
3452     gAPhiWidth3->SetMarkerStyle(MarkerAwayPhiFit);
3453     gAPhiWidth3->SetMarkerSize(MarkerSize);
3454     gAPhiWidth3->SetMarkerColor(ColorAwayPhiFit);
3455     gAPhiWidth3->SetLineColor(ColorAwayPhiFit);
3456
3457     gNPhiJt1->SetMarkerStyle(MarkerNearPhiFit);
3458     gNPhiJt1->SetMarkerSize(MarkerSize);
3459     gNPhiJt1->SetMarkerColor(ColorNearPhiFit);
3460     gNPhiJt1->SetLineColor(ColorNearPhiFit);
3461     gNPhiJt2->SetMarkerStyle(MarkerNearPhiFit);
3462     gNPhiJt2->SetMarkerSize(MarkerSize);
3463     gNPhiJt2->SetMarkerColor(ColorNearPhiFit);
3464     gNPhiJt2->SetLineColor(ColorNearPhiFit);
3465     gNPhiJt3->SetMarkerStyle(MarkerNearPhiFit);
3466     gNPhiJt3->SetMarkerSize(MarkerSize);
3467     gNPhiJt3->SetMarkerColor(ColorNearPhiFit);
3468     gNPhiJt3->SetLineColor(ColorNearPhiFit);
3469
3470
3471     gNYieldEta->SetMarkerStyle(MarkerNearEta);
3472     gAYieldEta->SetMarkerStyle(MarkerAwayEta);
3473     gNYieldEtaPt->SetMarkerStyle(MarkerNearEta);
3474     gAYieldEtaPt->SetMarkerStyle(MarkerAwayEta);
3475     gNYieldEta2->SetMarkerStyle(MarkerNearEta);
3476     gAYieldEta2->SetMarkerStyle(MarkerAwayEta);
3477     gNYieldEtaPt2->SetMarkerStyle(MarkerNearEta);
3478     gAYieldEtaPt2->SetMarkerStyle(MarkerAwayEta);
3479     gNYieldEta3->SetMarkerStyle(MarkerNearEta);
3480     gAYieldEta3->SetMarkerStyle(MarkerAwayEta);
3481     gNYieldEtaPt3->SetMarkerStyle(MarkerNearEta);
3482     gAYieldEtaPt3->SetMarkerStyle(MarkerAwayEta);
3483     gNYieldEta->SetMarkerColor(ColorNearEta);
3484     gAYieldEta->SetMarkerColor(ColorAwayEta);
3485     gNYieldEta->SetLineColor(ColorNearEta);
3486     gAYieldEta->SetLineColor(ColorAwayEta);
3487     gNYieldEtaPt->SetMarkerColor(ColorNearEta);
3488     gAYieldEtaPt->SetMarkerColor(ColorAwayEta);
3489     gNYieldEtaPt->SetLineColor(ColorNearEta);
3490     gAYieldEtaPt->SetLineColor(ColorAwayEta);
3491     gNYieldEta2->SetMarkerColor(ColorNearEta);
3492     gAYieldEta2->SetMarkerColor(ColorAwayEta);
3493     gNYieldEta2->SetLineColor(ColorNearEta);
3494     gAYieldEta2->SetLineColor(ColorAwayEta);
3495     gNYieldEtaPt2->SetMarkerColor(ColorNearEta);
3496     gAYieldEtaPt2->SetMarkerColor(ColorAwayEta);
3497     gNYieldEtaPt2->SetLineColor(ColorNearEta);
3498     gAYieldEtaPt2->SetLineColor(ColorAwayEta);
3499     gNYieldEta3->SetMarkerColor(ColorNearEta);
3500     gAYieldEta3->SetMarkerColor(ColorAwayEta);
3501     gNYieldEta3->SetLineColor(ColorNearEta);
3502     gAYieldEta3->SetLineColor(ColorAwayEta);
3503     gNYieldEtaPt3->SetMarkerColor(ColorNearEta);
3504     gAYieldEtaPt3->SetMarkerColor(ColorAwayEta);
3505     gNYieldEtaPt3->SetLineColor(ColorNearEta);
3506     gAYieldEtaPt3->SetLineColor(ColorAwayEta);
3507     gNYieldEta->SetMarkerSize(MarkerSize);
3508     gAYieldEta->SetMarkerSize(MarkerSize);
3509     gNYieldEtaPt->SetMarkerSize(MarkerSize);
3510     gAYieldEtaPt->SetMarkerSize(MarkerSize);
3511     gNYieldEta2->SetMarkerSize(MarkerSize);
3512     gAYieldEta2->SetMarkerSize(MarkerSize);
3513     gNYieldEtaPt2->SetMarkerSize(MarkerSize);
3514     gAYieldEtaPt2->SetMarkerSize(MarkerSize);
3515     gNYieldEta3->SetMarkerSize(MarkerSize);
3516     gAYieldEta3->SetMarkerSize(MarkerSize);
3517     gNYieldEtaPt3->SetMarkerSize(MarkerSize);
3518     gAYieldEtaPt3->SetMarkerSize(MarkerSize);
3519     gNYieldEtaPt3->SetMarkerSize(MarkerSize);
3520
3521     gNYieldEtaFit->SetMarkerStyle(MarkerNearEtaFit);
3522     gNYieldEtaFit->SetMarkerSize(MarkerSize);
3523     gNYieldEtaFit->SetMarkerColor(ColorNearEtaFit);
3524     gNYieldEtaFit->SetLineColor(ColorNearEtaFit);
3525     gNYieldEtaFit2->SetMarkerStyle(MarkerNearEtaFit);
3526     gNYieldEtaFit2->SetMarkerSize(MarkerSize);
3527     gNYieldEtaFit2->SetMarkerColor(ColorNearEtaFit);
3528     gNYieldEtaFit2->SetLineColor(ColorNearEtaFit);
3529     gNYieldEtaFit3->SetMarkerStyle(MarkerNearEtaFit);
3530     gNYieldEtaFit3->SetMarkerSize(MarkerSize);
3531     gNYieldEtaFit3->SetMarkerColor(ColorNearEtaFit);
3532     gNYieldEtaFit3->SetLineColor(ColorNearEtaFit);
3533
3534     gNYieldEtaFitPt->SetMarkerStyle(MarkerNearEtaFit);
3535     gNYieldEtaFitPt->SetMarkerSize(MarkerSize);
3536     gNYieldEtaFitPt->SetMarkerColor(ColorNearEtaFit);
3537     gNYieldEtaFitPt->SetLineColor(ColorNearEtaFit);
3538     gNYieldEtaFitPt2->SetMarkerStyle(MarkerNearEtaFit);
3539     gNYieldEtaFitPt2->SetMarkerSize(MarkerSize);
3540     gNYieldEtaFitPt2->SetMarkerColor(ColorNearEtaFit);
3541     gNYieldEtaFitPt2->SetLineColor(ColorNearEtaFit);
3542     gNYieldEtaFitPt3->SetMarkerStyle(MarkerNearEtaFit);
3543     gNYieldEtaFitPt3->SetMarkerSize(MarkerSize);
3544     gNYieldEtaFitPt3->SetMarkerColor(ColorNearEtaFit);
3545     gNYieldEtaFitPt3->SetLineColor(ColorNearEtaFit);
3546
3547     gNEtaWidth1->SetMarkerStyle(MarkerNearEtaFit);
3548     gNEtaWidth1->SetMarkerSize(MarkerSize);
3549     gNEtaWidth1->SetMarkerColor(ColorNearEtaFit);
3550     gNEtaWidth1->SetLineColor(ColorNearEtaFit);
3551     gNEtaWidth2->SetMarkerStyle(MarkerNearEtaFit);
3552     gNEtaWidth2->SetMarkerSize(MarkerSize);
3553     gNEtaWidth2->SetMarkerColor(ColorNearEtaFit);
3554     gNEtaWidth2->SetLineColor(ColorNearEtaFit);
3555     gNEtaWidth3->SetMarkerStyle(MarkerNearEtaFit);
3556     gNEtaWidth3->SetMarkerSize(MarkerSize);
3557     gNEtaWidth3->SetMarkerColor(ColorNearEtaFit);
3558     gNEtaWidth3->SetLineColor(ColorNearEtaFit);
3559
3560     gNEtaJt1->SetMarkerStyle(MarkerNearEtaFit);
3561     gNEtaJt1->SetMarkerSize(MarkerSize);
3562     gNEtaJt1->SetMarkerColor(ColorNearEtaFit);
3563     gNEtaJt1->SetLineColor(ColorNearEtaFit);
3564     gNEtaJt2->SetMarkerStyle(MarkerNearEtaFit);
3565     gNEtaJt2->SetMarkerSize(MarkerSize);
3566     gNEtaJt2->SetMarkerColor(ColorNearEtaFit);
3567     gNEtaJt2->SetLineColor(ColorNearEtaFit);
3568     gNEtaJt3->SetMarkerStyle(MarkerNearEtaFit);
3569     gNEtaJt3->SetMarkerSize(MarkerSize);
3570     gNEtaJt3->SetMarkerColor(ColorNearEtaFit);
3571     gNEtaJt3->SetLineColor(ColorNearEtaFit);
3572  
3573     gNAvePhi1->SetMarkerStyle(MarkerNearPhi);
3574     gNAvePhi1->SetMarkerSize(MarkerSize);
3575     gNAvePhi1->SetMarkerColor(ColorNearPhi);
3576     gNAvePhi1->SetLineColor(ColorNearPhi);
3577     gAAvePhi1->SetMarkerStyle(MarkerAwayPhi);
3578     gAAvePhi1->SetMarkerSize(MarkerSize);
3579     gAAvePhi1->SetMarkerColor(ColorAwayPhi);
3580     gAAvePhi1->SetLineColor(ColorAwayPhi);
3581     gMAvePhi1->SetMarkerStyle(MarkerMin);
3582     gMAvePhi1->SetMarkerSize(MarkerSize);
3583     gMAvePhi1->SetMarkerColor(ColorMin);
3584     gMAvePhi1->SetLineColor(ColorMin);
3585  
3586     gNAvePhi2->SetMarkerStyle(MarkerNearPhi);
3587     gNAvePhi2->SetMarkerSize(MarkerSize);
3588     gNAvePhi2->SetMarkerColor(ColorNearPhi);
3589     gNAvePhi2->SetLineColor(ColorNearPhi);
3590     gAAvePhi2->SetMarkerStyle(MarkerAwayPhi);
3591     gAAvePhi2->SetMarkerSize(MarkerSize);
3592     gAAvePhi2->SetMarkerColor(ColorAwayPhi);
3593     gAAvePhi2->SetLineColor(ColorAwayPhi);
3594     gMAvePhi2->SetMarkerStyle(MarkerMin);
3595     gMAvePhi2->SetMarkerSize(MarkerSize);
3596     gMAvePhi2->SetMarkerColor(ColorMin);
3597     gMAvePhi2->SetLineColor(ColorMin);
3598
3599
3600     gNAvePhiFit1->SetMarkerStyle(MarkerNearPhiFit);
3601     gNAvePhiFit1->SetMarkerSize(MarkerSize);
3602     gNAvePhiFit1->SetMarkerColor(ColorNearPhiFit);
3603     gNAvePhiFit1->SetLineColor(ColorNearPhiFit);
3604     gAAvePhiFit1->SetMarkerStyle(MarkerAwayPhiFit);
3605     gAAvePhiFit1->SetMarkerSize(MarkerSize);
3606     gAAvePhiFit1->SetMarkerColor(ColorAwayPhiFit);
3607     gAAvePhiFit1->SetLineColor(ColorAwayPhiFit);
3608     gMAvePhiFit1->SetMarkerStyle(MarkerMinFit);
3609     gMAvePhiFit1->SetMarkerSize(MarkerSize);
3610     gMAvePhiFit1->SetMarkerColor(ColorMinFit);
3611     gMAvePhiFit1->SetLineColor(ColorMinFit);
3612   
3613     gNAvePhiFit2->SetMarkerStyle(MarkerNearPhiFit);
3614     gNAvePhiFit2->SetMarkerSize(MarkerSize);
3615     gNAvePhiFit2->SetMarkerColor(ColorNearPhiFit);
3616     gNAvePhiFit2->SetLineColor(ColorNearPhiFit);
3617     gAAvePhiFit2->SetMarkerStyle(MarkerAwayPhiFit);
3618     gAAvePhiFit2->SetMarkerSize(MarkerSize);
3619     gAAvePhiFit2->SetMarkerColor(ColorAwayPhiFit);
3620     gAAvePhiFit2->SetLineColor(ColorAwayPhiFit);
3621     gMAvePhiFit2->SetMarkerStyle(MarkerMinFit);
3622     gMAvePhiFit2->SetMarkerSize(MarkerSize);
3623     gMAvePhiFit2->SetMarkerColor(ColorMinFit);
3624     gMAvePhiFit2->SetLineColor(ColorMinFit);
3625    
3626     char outName[200];
3627     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);
3628     TFile *fout=new TFile(name,"recreate");
3629    
3630    
3631     float plotmin=100, plotmax=-100;
3632     plotmin2=100; plotmax2=-100;
3633     plotmin3=100; plotmax3=-100;
3634     float plotminW=100, plotmaxW=-100;
3635     float plotminJ=100, plotmaxJ=-100;
3636     float maxheight=100;
3637     float plotminAve=100, plotmaxAve=-100;
3638     for(int i=0;i<=2;i+=2){
3639       for(int j=0;j<nMainLoop;j++){
3640         if(NYieldPhiZYAM[i][j]<plotmin)plotmin=NYieldPhiZYAM[i][j];
3641         if(NYieldPhiZYAM[i][j]>plotmax&&NYieldPhiZYAM[i][j]<maxheight)plotmax=NYieldPhiZYAM[i][j];
3642         if(AYieldPhiZYAM[i][j]<plotmin)plotmin=AYieldPhiZYAM[i][j];
3643         if(AYieldPhiZYAM[i][j]>plotmax&&AYieldPhiZYAM[i][j]<maxheight)plotmax=AYieldPhiZYAM[i][j];
3644         if(NYieldEtaZYAM[i][j]<plotmin)plotmin=NYieldEtaZYAM[i][j];
3645         if(NYieldEtaZYAM[i][j]>plotmax&&NYieldEtaZYAM[i][j]<maxheight)plotmax=NYieldEtaZYAM[i][j];
3646         if(AYieldEtaZYAM[i][j]<plotmin)plotmin=AYieldEtaZYAM[i][j];
3647         if(AYieldEtaZYAM[i][j]>plotmax&&AYieldEtaZYAM[i][j]<maxheight)plotmax=AYieldEtaZYAM[i][j];
3648         if(MYieldPhi[i][j]<plotmin2)plotmin2=MYieldPhi[0][j];
3649         if(MYieldPhi[i][j]>plotmax2&&MYieldPhi[0][j]<maxheight)plotmax2=MYieldPhi[0][j];
3650         if(MYieldPhi[2][j]<plotmin3)plotmin3=MYieldPhi[2][j];
3651         if(MYieldPhi[2][j]>plotmax3&&MYieldPhi[2][j]<maxheight)plotmax3=MYieldPhi[2][j];
3652         if(DrawFit){
3653           if(NYieldPhiFit[i][j]<plotmin)plotmin=NYieldPhiFit[i][j];
3654           if(NYieldPhiFit[i][j]>plotmax&&NYieldPhiFit[i][j]<maxheight)plotmax=NYieldPhiFit[i][j];
3655           if(AYieldPhiFit[i][j]<plotmin)plotmin=AYieldPhiFit[i][j];
3656           if(AYieldPhiFit[i][j]>plotmax&&AYieldPhiFit[i][j]<maxheight)plotmax=AYieldPhiFit[i][j];
3657           if(MYieldPhiFit[0][j]<plotmin2)plotmin2=MYieldPhiFit[0][j];
3658           if(MYieldPhiFit[0][j]>plotmax2&&MYieldPhiFit[0][j]<maxheight)plotmax2=MYieldPhiFit[0][j];
3659           if(MYieldPhiFit[2][j]<plotmin3)plotmin3=MYieldPhiFit[2][j];
3660           if(MYieldPhiFit[2][j]>plotmax3&&MYieldPhiFit[2][j]<maxheight)plotmax3=MYieldPhiFit[2][j];
3661         }
3662         if(i==0){
3663           if(NWidthPhi[0][j]<plotminW)plotminW=NWidthPhi[0][j];
3664           if(NWidthPhi[0][j]>plotmaxW&&NWidthPhi[0][j]<5)plotmaxW=NWidthPhi[0][j];
3665           if(AWidthPhi[0][j]<plotminW)plotminW=AWidthPhi[0][j];
3666           if(AWidthPhi[0][j]>plotmaxW&&AWidthPhi[0][j]<6)plotmaxW=AWidthPhi[0][j];
3667           if(NJtPhi[0][j]<plotminJ)plotminJ=NJtPhi[0][j];
3668           if(NJtPhi[0][j]>plotmaxJ&&NJtPhi[0][j]<5)plotmaxJ=NJtPhi[0][j];
3669           if(AJtPhi[0][j]<plotminJ)plotminJ=AJtPhi[0][j];
3670           if(AJtPhi[0][j]>plotmaxJ&&AJtPhi[0][j]<6)plotmaxJ=AJtPhi[0][j];
3671           if(NAvePhi[0][j]<plotminAve)plotminAve=NAvePhi[0][j];
3672           if(NAvePhi[0][j]>plotmaxAve&&NAvePhi[0][j]<5)plotmaxW=NAvePhi[0][j];
3673           if(AAvePhi[0][j]<plotminAve)plotminAve=AAvePhi[0][j];
3674           if(AAvePhi[0][j]>plotmaxAve&&AAvePhi[0][j]<6)plotmaxAve=AAvePhi[0][j];
3675         }
3676       }
3677     }
3678     plotmin/=1.2-0.2;
3679     plotmax*=1.2+0.2;
3680     plotmin2/=1.5-0.2;
3681     plotmax2*=1.5+0.2;
3682     plotmin3/=1.5-0.2;
3683     plotmax3*=1.5+0.2;
3684     if(plotmax>maxheight)plotmax=maxheight;
3685     if(plotmax2>maxheight)plotmax2=maxheight;
3686     if(plotmax3>maxheight)plotmax3=maxheight;
3687     plotminW/1.5-0.2;
3688     plotmaxW*=1.5+0.2;
3689     plotmaxJ*=1.5+0.2;
3690     plotmaxAve*=1.5+1;
3691     plotminAve/=1.6-0.2;
3692     plotmin=0;
3693     plotmin2=0;
3694     plotmin3=0;
3695     plotminW=0;
3696     plotminJ=0;
3697     plotminAve=0;
3698     //plotminAve=0;
3699     if(plotmin<=0)plotmin=-0.00001;
3700     if(plotmin2<=0)plotmin2=-0.00001;
3701     if(plotmin3<=0)plotmin3=-0.00001;
3702     if(plotminW<=0)plotminW=-0.00001;
3703     if(plotminAve<=0)plotminAve=-0.00001;
3704     plotmaxW=1;
3705
3706     cTYield=new TCanvas("cTYield","P_{T}^{Trig} Dependence of Yields",800,600);
3707     SetMargins1D(cTYield);
3708     sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3709     TH2F *hTYield=new TH2F("hTYield",name,10,0,TPt2+1,10,plotmin,plotmax);
3710     if(NoTitle)hTYield->SetTitle("");
3711     hTYield->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3712     hTYield->GetXaxis()->SetTitleColor(1);
3713     hTYield->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
3714     SetTitles1D(hTYield);
3715     hTYield->Draw();
3716     //cTYield->SetLogy(1);
3717     gNYieldPhi->Draw("p");
3718     gAYieldPhi->Draw("p");
3719     if(DrawFit)gNYieldPhiFit->Draw("p");
3720     if(DrawFit)gAYieldPhiFit->Draw("p");
3721     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3722     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3723     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3724     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3725     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3726     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);
3727     cTYield->SaveAs(outName);
3728
3729     cTYieldPt=new TCanvas("cTYieldPt","P_{T}^{Trig} Dependence of Peak P_{T}",800,600);
3730     SetMargins1D(cTYieldPt);
3731     sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3732     TH2F *hTYieldPt=new TH2F("hTYieldPt",name,10,0,TPt2+1,10,plotmin,plotmax);
3733     if(NoTitle)hTYieldPt->SetTitle("");
3734     hTYieldPt->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3735     hTYieldPt->GetXaxis()->SetTitleColor(1);
3736     hTYieldPt->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
3737     SetTitles1D(hTYieldPt);
3738     hTYieldPt->Draw();
3739     // cTYieldPt->SetLogy(1);
3740     gNYieldPhiPt->Draw("p");
3741     gAYieldPhiPt->Draw("p");
3742     if(DrawFit)gNYieldPhiFitPt->Draw("p");
3743     if(DrawFit)gAYieldPhiFitPt->Draw("p");
3744     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3745     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3746     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3747     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3748     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3749     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);
3750     cTYieldPt->SaveAs(outName);
3751
3752     cTYield2=new TCanvas("cTYield2","P_{T}^{Trig} Dependence of Yields",800,600);
3753     SetMargins1D(cTYield2);
3754     sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3755     TH2F *hTYield2=new TH2F("hTYield2",name,10,0,TPt2+1,10,plotmin,plotmax);
3756     if(NoTitle)hTYield2->SetTitle("");
3757     hTYield2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3758     hTYield2->GetXaxis()->SetTitleColor(1);
3759     hTYield2->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
3760     SetTitles1D(hTYield2);
3761     hTYield2->Draw();
3762     //cTYield2->SetLogy(1);
3763     gNYieldPhi2->Draw("p");
3764     gAYieldPhi2->Draw("p");
3765     if(DrawFit)gNYieldPhiFit2->Draw("p");
3766     if(DrawFit)gAYieldPhiFit2->Draw("p");
3767     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3768     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3769     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3770     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3771     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3772     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);
3773     cTYield2->SaveAs(outName);
3774
3775     cTYieldPt2=new TCanvas("cTYieldPt2","P_{T}^{Trig} Dependence of Peak P_{T}",800,600);
3776     SetMargins1D(cTYieldPt2);
3777     sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3778     TH2F *hTYieldPt2=new TH2F("hTYieldPt2",name,10,0,TPt2+1,10,plotmin,plotmax);
3779     if(NoTitle)hTYieldPt2->SetTitle("");
3780     hTYieldPt2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3781     hTYieldPt2->GetXaxis()->SetTitleColor(1);
3782     hTYieldPt2->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
3783     SetTitles1D(hTYieldPt2);
3784     hTYieldPt2->Draw();
3785     //cTYieldPt2->SetLogy(1);
3786     gNYieldPhiPt2->Draw("p");
3787     gAYieldPhiPt2->Draw("p");
3788     if(DrawFit)gNYieldPhiFitPt2->Draw("p");
3789     if(DrawFit)gAYieldPhiFitPt2->Draw("p");
3790     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3791     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3792     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3793     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3794     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3795     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);
3796     cTYieldPt2->SaveAs(outName);
3797
3798     //low
3799     cTYield3=new TCanvas("cTYield3","P_{T}^{Trig} Dependence of Yields",800,600);
3800     SetMargins1D(cTYield3);
3801     sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3802     TH2F *hTYield3=new TH2F("hTYield3",name,10,0,TPt2+1,10,plotmin,plotmax);
3803     if(NoTitle)hTYield3->SetTitle("");
3804     hTYield3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3805     hTYield3->GetXaxis()->SetTitleColor(1);
3806     hTYield3->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
3807     SetTitles1D(hTYield2);
3808     hTYield3->Draw();
3809     //cTYield2->SetLogy(1);
3810     gNYieldPhi3->Draw("p");
3811     gAYieldPhi3->Draw("p");
3812     if(DrawFit)gNYieldPhiFit3->Draw("p");
3813     if(DrawFit)gAYieldPhiFit3->Draw("p");
3814     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3815     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3816     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3817     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3818     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3819     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);
3820     cTYield3->SaveAs(outName);
3821
3822     cTYieldPt3=new TCanvas("cTYieldPt3","P_{T}^{Trig} Dependence of Peak P_{T}",800,600);
3823     SetMargins1D(cTYieldPt3);
3824     sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3825     TH2F *hTYieldPt3=new TH2F("hTYieldPt3",name,10,0,TPt2+1,10,plotmin,plotmax);
3826     if(NoTitle)hTYieldPt3->SetTitle("");
3827     hTYieldPt3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3828     hTYieldPt3->GetXaxis()->SetTitleColor(1);
3829     hTYieldPt3->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
3830     SetTitles1D(hTYieldPt3);
3831     hTYieldPt3->Draw();
3832     //cTYieldPt2->SetLogy(1);
3833     gNYieldPhiPt3->Draw("p");
3834     gAYieldPhiPt3->Draw("p");
3835     if(DrawFit)gNYieldPhiFitPt3->Draw("p");
3836     if(DrawFit)gAYieldPhiFitPt3->Draw("p");
3837     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3838     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3839     keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3840     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3841     if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3842     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);
3843     cTYieldPt3->SaveAs(outName);
3844
3845
3846
3847     cTYieldE=new TCanvas("cTYieldE","P_{T}^{Trig} Dependence of Eta Yields",800,600);
3848     SetMargins1D(cTYieldE);
3849     sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3850     TH2F *hTYield=new TH2F("hTYieldE",name,10,0,TPt2+1,10,plotmin,plotmax);
3851     if(NoTitle)hTYieldE->SetTitle("");
3852     hTYieldE->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3853     hTYieldE->GetXaxis()->SetTitleColor(1);
3854     hTYieldE->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
3855     SetTitles1D(hTYieldE);
3856     hTYieldE->Draw();
3857     //cTYield->SetLogy(1);
3858     gNYieldEta->Draw("p");
3859     gAYieldEta->Draw("p");
3860     if(DrawFit)gNYieldEtaFit->Draw("p");
3861     // if(DrawFit)gAYieldEtaFit->Draw("p");
3862     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3863     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
3864     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
3865     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3866     //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
3867     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);
3868     cTYieldE->SaveAs(outName);
3869
3870     cTYieldPtE=new TCanvas("cTYieldPtE","P_{T}^{Trig} Dependence of Peak P_{T} Eta",800,600);
3871     SetMargins1D(cTYieldPtE);
3872     sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3873     TH2F *hTYieldPtE=new TH2F("hTYieldPtE",name,10,0,TPt2+1,10,plotmin,plotmax);
3874     if(NoTitle)hTYieldPtE->SetTitle("");
3875     hTYieldPtE->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3876     hTYieldPtE->GetXaxis()->SetTitleColor(1);
3877     hTYieldPtE->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
3878     SetTitles1D(hTYieldPtE);
3879     hTYieldPtE->Draw();
3880     // cTYieldPt->SetLogy(1);
3881     gNYieldEtaPt->Draw("p");
3882     gAYieldEtaPt->Draw("p");
3883     if(DrawFit)gNYieldEtaFitPt->Draw("p");
3884     //if(DrawFit)gAYieldEtaFitPt->Draw("p");
3885     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
3886     keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
3887     keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
3888     if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3889     //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
3890     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);
3891     cTYieldPt->SaveAs(outName);
3892
3893   
3894     cTYieldC=new TCanvas("cTYieldC","P_{T}^{Trig} Dependence of Yields",800,600);
3895     SetMargins1D(cTYieldC);
3896     sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3897     TH2F *hTYieldC=new TH2F("hTYieldC",name,10,0,TPt2+1,10,plotmin,plotmax);
3898     if(NoTitle)hTYieldC->SetTitle("");
3899     hTYieldC->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3900     hTYieldC->GetXaxis()->SetTitleColor(1);
3901     hTYieldC->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
3902     SetTitles1D(hTYieldC);
3903     hTYieldC->Draw();
3904     //cTYield->SetLogy(1);
3905     gNYieldPhi->Draw("p");
3906     gAYieldPhi->Draw("p");
3907     if(DrawFit)gNYieldPhiFit->Draw("p");
3908     if(DrawFit)gAYieldPhiFit->Draw("p");
3909     gNYieldEta->Draw("p");
3910     gAYieldEta->Draw("p");
3911     if(DrawFit)gNYieldEtaFit->Draw("p");
3912     // if(DrawFit)gAYieldEtaFit->Draw("p");
3913     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
3914     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3915     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3916     if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3917     if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3918     keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
3919     keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
3920     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3921     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);
3922     cTYieldC->SaveAs(outName);
3923
3924     cTYieldPtC=new TCanvas("cTYieldPtC","P_{T}^{Trig} Dependence of Yields",800,600);
3925     SetMargins1D(cTYieldPtC);
3926     sprintf(name,"Peak p_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3927     TH2F *hTYieldPtC=new TH2F("hTYieldPtC",name,10,0,TPt2+1,10,plotmin,plotmax);
3928     if(NoTitle)hTYieldPtC->SetTitle("");
3929     hTYieldPtC->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3930     hTYieldPtC->GetXaxis()->SetTitleColor(1);
3931     hTYieldPtC->GetYaxis()->SetTitle("#frac{p_{T}^{ch}}{N_{Trigger}}    ");
3932     SetTitles1D(hTYieldPtC);
3933     hTYieldPtC->Draw();
3934     //cTYield->SetLogy(1);
3935     gNYieldPhiPt->Draw("p");
3936     gAYieldPhiPt->Draw("p");
3937     if(DrawFit)gNYieldPhiFitPt->Draw("p");
3938     if(DrawFit)gAYieldPhiFitPt->Draw("p");
3939     gNYieldEtaPt->Draw("p");
3940     gAYieldEtaPt->Draw("p");
3941     if(DrawFit)gNYieldEtaFitPt->Draw("p");
3942     // if(DrawFit)gAYieldEtaFit->Draw("p");
3943     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
3944     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3945     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3946     if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3947     if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3948     keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
3949     keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
3950     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3951     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);
3952     cTYieldPtC->SaveAs(outName);
3953
3954     //
3955     cTYieldC2=new TCanvas("cTYieldC2","P_{T}^{Trig} Dependence of Yields 2",800,600);
3956     SetMargins1D(cTYieldC2);
3957     sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3958     TH2F *hTYieldC2=new TH2F("hTYieldC2",name,10,0,TPt2+1,10,plotmin,plotmax);
3959     if(NoTitle)hTYieldC2->SetTitle("");
3960     hTYieldC2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3961     hTYieldC2->GetXaxis()->SetTitleColor(1);
3962     hTYieldC2->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
3963     SetTitles1D(hTYieldC2);
3964     hTYieldC2->Draw();
3965     //cTYield->SetLogy(1);
3966     gNYieldPhi2->Draw("p");
3967     gAYieldPhi2->Draw("p");
3968     if(DrawFit)gNYieldPhiFit2->Draw("p");
3969     if(DrawFit)gAYieldPhiFit2->Draw("p");
3970     gNYieldEta2->Draw("p");
3971     gAYieldEta2->Draw("p");
3972     if(DrawFit)gNYieldEtaFit2->Draw("p");
3973     // if(DrawFit)gAYieldEtaFit->Draw("p");
3974     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
3975     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
3976     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
3977     if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
3978     if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
3979     keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
3980     keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
3981     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
3982     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);
3983     cTYieldC2->SaveAs(outName);
3984
3985     cTYieldPtC2=new TCanvas("cTYieldPtC2","P_{T}^{Trig} Dependence of Yields",800,600);
3986     SetMargins1D(cTYieldPtC2);
3987     sprintf(name,"Peak p_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
3988     TH2F *hTYieldPtC2=new TH2F("hTYieldPtC2",name,10,0,TPt2+1,10,plotmin,plotmax);
3989     if(NoTitle)hTYieldPtC2->SetTitle("");
3990     hTYieldPtC2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
3991     hTYieldPtC2->GetXaxis()->SetTitleColor(1);
3992     hTYieldPtC2->GetYaxis()->SetTitle("#frac{p_{T}^{ch}}{N_{Trigger}}    ");
3993     SetTitles1D(hTYieldPtC2);
3994     hTYieldPtC2->Draw();
3995     //cTYield->SetLogy(1);
3996     gNYieldPhiPt2->Draw("p");
3997     gAYieldPhiPt2->Draw("p");
3998     if(DrawFit)gNYieldPhiFitPt2->Draw("p");
3999     if(DrawFit)gAYieldPhiFitPt2->Draw("p");
4000     gNYieldEtaPt2->Draw("p");
4001     gAYieldEtaPt2->Draw("p");
4002     if(DrawFit)gNYieldEtaFitPt2->Draw("p");
4003     // if(DrawFit)gAYieldEtaFit->Draw("p");
4004     sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
4005     keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
4006     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
4007     if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4008     if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4009     keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
4010     keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
4011     if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
4012     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);
4013     cTYieldPtC2->SaveAs(outName);
4014
4015
4016     //
4017     cTMin=new TCanvas("cTMin","P_{T}^{Trig} Dependence of Underlying Event",800,600);
4018     SetMargins1D(cTMin);
4019     sprintf(name,"Underlying Event %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4020     TH2F *hTMin=new TH2F("hTMin",name,10,0,TPt2+1,10,plotmin2,plotmax2);
4021     if(NoTitle)hTMin->SetTitle("");
4022     hTMin->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4023     hTMin->GetXaxis()->SetTitleColor(1);
4024     hTMin->GetYaxis()->SetTitle("#frac{p_{T}^{ch}}{N_{Trigger}}    ");
4025     SetTitles1D(hTMin);
4026     hTMin->Draw();
4027     // cTMin->SetLogy(1);
4028     gMYieldPhi->Draw("p");
4029     if(DrawFit)gMYieldPhiFit->Draw("p");
4030     sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
4031     keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4032     if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4033     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);
4034     cTMin->SaveAs(outName);
4035
4036     cTMinPt=new TCanvas("cTMinPt","P_{T}^{Trig} Dependence of Underlying Event P_{T}",800,600);
4037     SetMargins1D(cTMinPt);
4038     sprintf(name,"Min P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4039     TH2F *hTMinPt=new TH2F("hTMinPt",name,10,0,TPt2+1,10,plotmin3,plotmax3);
4040     if(NoTitle)hTMinPt->SetTitle("");
4041     hTMinPt->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4042     hTMinPt->GetXaxis()->SetTitleColor(1);
4043     hTMinPt->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
4044     SetTitles1D(hTMinPt);
4045     hTMinPt->Draw();
4046     //cTMinPt->SetLogy(1);
4047     gMYieldPhiPt->Draw("p");
4048     if(DrawFit)gMYieldPhiFitPt->Draw("p");
4049     sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
4050     keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4051     if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4052     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);
4053     cTMinPt->SaveAs(outName);
4054
4055     cTMin2=new TCanvas("cTMin2","P_{T}^{Trig} Dependence of Underlying Event",800,600);
4056     SetMargins1D(cTMin2);
4057     sprintf(name,"Underlying Event %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4058     TH2F *hTMin2=new TH2F("hTMin2",name,10,0,TPt2+1,10,plotmin2,plotmax2);
4059     if(NoTitle)hTMin2->SetTitle("");
4060     hTMin2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4061     hTMin2->GetXaxis()->SetTitleColor(1);
4062     hTMin2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}    ");
4063     SetTitles1D(hTMin2);
4064     hTMin2->Draw();
4065     //cTMin2->SetLogy(1);
4066     gMYieldPhi2->Draw("p");
4067     if(DrawFit)gMYieldPhiFit2->Draw("p");
4068     sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
4069      keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4070     if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4071     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);
4072     cTMin2->SaveAs(outName);
4073
4074     cTMinPt2=new TCanvas("cTMinPt2","P_{T}^{Trig} Dependence of Underlying Event P_{T}",800,600);
4075     SetMargins1D(cTMinPt2);
4076     sprintf(name,"Min P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4077     TH2F *hTMinPt2=new TH2F("hTMinPt2",name,10,0,TPt2+1,10,plotmin3,plotmax3);
4078     if(NoTitle)hTMinPt2->SetTitle("");
4079     hTMinPt2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4080     hTMinPt2->GetXaxis()->SetTitleColor(1);
4081     hTMinPt2->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
4082     SetTitles1D(hTMinPt2);
4083     hTMinPt2->Draw();
4084     //cTMinPt2->SetLogy(1);
4085     gMYieldPhiPt2->Draw("p");
4086     if(DrawFit)gMYieldPhiFitPt2->Draw("p");
4087     sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
4088     keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4089     if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4090     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);
4091     cTMinPt2->SaveAs(outName); 
4092
4093     cTMin3=new TCanvas("cTMin3","P_{T}^{Trig} Dependence of Underlying Event",800,600);
4094     SetMargins1D(cTMin3);
4095     sprintf(name,"Underlying Event %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4096     TH2F *hTMin3=new TH2F("hTMin3",name,10,0,TPt2+1,10,plotmin2,plotmax2);
4097     if(NoTitle)hTMin3->SetTitle("");
4098     hTMin3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4099     hTMin3->GetXaxis()->SetTitleColor(1);
4100     hTMin3->GetYaxis()->SetTitle("#frac{N}{N_{Trigger}}    ");
4101     SetTitles1D(hTMin3);
4102     hTMin3->Draw();
4103     //cTMin2->SetLogy(1);
4104     gMYieldPhi3->Draw("p");
4105     if(DrawFit)gMYieldPhiFit3->Draw("p");
4106     sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
4107     keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4108     if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4109     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);
4110     cTMin3->SaveAs(outName);
4111
4112     cTMinPt3=new TCanvas("cTMinPt3","P_{T}^{Trig} Dependence of Underlying Event P_{T}",800,600);
4113     SetMargins1D(cTMinPt3);
4114     sprintf(name,"Min P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4115     TH2F *hTMinPt3=new TH2F("hTMinPt3",name,10,0,TPt2+1,10,plotmin3,plotmax3);
4116     if(NoTitle)hTMinPt3->SetTitle("");
4117     hTMinPt3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4118     hTMinPt3->GetXaxis()->SetTitleColor(1);
4119     hTMinPt3->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
4120     SetTitles1D(hTMinPt3);
4121     hTMinPt3->Draw();
4122     //cTMinPt2->SetLogy(1);
4123     gMYieldPhiPt3->Draw("p");
4124     if(DrawFit)gMYieldPhiFitPt3->Draw("p");
4125     sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
4126     keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4127     if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4128     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);
4129     cTMinPt3->SaveAs(outName); 
4130     cWidth1=new TCanvas("cWidth1","Width MidPoint",800,600);
4131     SetMargins1D(cWidth1);
4132     sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
4133     TH2F *hWidth1=new TH2F("hWidth1",name,10,0,TPt2+1,10,plotminW,plotmaxW);
4134     if(NoTitle)hWidth1->SetTitle("");
4135     hWidth1->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
4136     hWidth1->GetXaxis()->SetTitleColor(1);
4137     hWidth1->GetYaxis()->SetTitle("#sigma (radians)   ");
4138     SetTitles1D(hWidth1);
4139     hWidth1->Draw();
4140     gNPhiWidth1->Draw("p");
4141     gAPhiWidth1->Draw("p");
4142     gNEtaWidth1->Draw("p");
4143     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4144     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4145     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
4146     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);
4147     cWidth1->SaveAs(outName);
4148
4149     cWidth2=new TCanvas("cWidth2","Width Average",800,600);
4150     SetMargins1D(cWidth2);
4151     sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
4152     TH2F *hWidth2=new TH2F("hWidth2",name,10,0,TPt2+1,10,plotminW,plotmaxW);
4153     if(NoTitle)hWidth2->SetTitle("");
4154     hWidth2->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
4155     hWidth2->GetXaxis()->SetTitleColor(1);
4156     hWidth2->GetYaxis()->SetTitle("#sigma (radians)   ");
4157     SetTitles1D(hWidth2);
4158     hWidth2->Draw();
4159     gNPhiWidth2->Draw("p");
4160     gAPhiWidth2->Draw("p");
4161     gNEtaWidth2->Draw("p");
4162     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4163     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4164     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
4165     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);
4166     cWidth2->SaveAs(outName);
4167
4168     cWidth3=new TCanvas("cWidth3","Width Low Err",800,600);
4169     SetMargins1D(cWidth3);
4170     sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
4171     TH2F *hWidth3=new TH2F("hWidth3",name,10,0,TPt2+1,10,plotminW,plotmaxW);
4172     if(NoTitle)hWidth3->SetTitle("");
4173     hWidth3->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
4174     hWidth3->GetXaxis()->SetTitleColor(1);
4175     hWidth3->GetYaxis()->SetTitle("#sigma (radians)   ");
4176     SetTitles1D(hWidth3);
4177     hWidth3->Draw();
4178     gNPhiWidth3->Draw("p");
4179     gAPhiWidth3->Draw("p");
4180     gNEtaWidth3->Draw("p");
4181     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4182     keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4183     keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
4184     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);
4185     cWidth3->SaveAs(outName);
4186
4187     cJt1=new TCanvas("cJt1","Jt MidPoint",800,600);
4188     SetMargins1D(cJt1);
4189     sprintf(name,"Peak Jt %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
4190     TH2F *hJt1=new TH2F("hJt1",name,10,0,TPt2+1,10,plotminJ,plotmaxJ);
4191     if(NoTitle)hJt1->SetTitle("");
4192     hJt1->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
4193     hJt1->GetXaxis()->SetTitleColor(1);
4194     hJt1->GetYaxis()->SetTitle("#sqrt{<j_{T}^{2}>}   ");
4195     SetTitles1D(hJt1);
4196     hJt1->Draw();
4197     gNPhiJt1->Draw("p");
4198     //  gAPhiJt1->Draw("p");
4199     gNEtaJt1->Draw("p");
4200     keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4201     // keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4202     keySymbol(.65,.8,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
4203     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);
4204     cJt1->SaveAs(outName);
4205
4206     cTAve=new TCanvas("cTAve","P_{T}^{Trig} Dependence of <p_{T}>",800,600);
4207     SetMargins1D(cTAve);
4208     sprintf(name,"<p_{T}^{Assoc}> %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4209     TH2F *hTAve=new TH2F("hTAve",name,10,0,TPt2+1,10,plotminAve,plotmaxAve);
4210     if(NoTitle)hTAve->SetTitle("");
4211     hTAve->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4212     hTAve->GetXaxis()->SetTitleColor(1);
4213     hTAve->GetYaxis()->SetTitle("<p_{T}^{Assoc}>    ");
4214     SetTitles1D(hTAve);
4215     hTAve->Draw();
4216     //cTYield->SetLogy(1);
4217     gNAvePhi1->Draw("p");
4218     gAAvePhi1->Draw("p");
4219     gMAvePhi1->Draw("p");
4220     if(DrawFit)gNAvePhiFit1->Draw("p");
4221     if(DrawFit)gAAvePhiFit1->Draw("p");
4222     if(DrawFit)gMAvePhiFit1->Draw("p");
4223     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
4224     keySymbol(.50,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
4225     keySymbol(.50,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
4226     keySymbol(.50,.75,"Underlying Event",ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4227     if(DrawFit)keySymbol(.5,.70,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4228     if(DrawFit)keySymbol(.5,.65,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4229     if(DrawFit)keySymbol(.50,.6,"Underlying Event Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4230     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);
4231     cTAve->SaveAs(outName);
4232
4233     cTAve2=new TCanvas("cTAve2","P_{T}^{Trig} Dependence of <p_{T}>",800,600);
4234     SetMargins1D(cTAve2);
4235     sprintf(name,"<p_{T}^{Assoc}> %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
4236     TH2F *hTAve2=new TH2F("hTAve2",name,10,0,TPt2+1,10,plotminAve,plotmaxAve);
4237     if(NoTitle)hTAve2->SetTitle("");
4238     hTAve2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
4239     hTAve2->GetXaxis()->SetTitleColor(1);
4240     hTAve2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>    ");
4241     SetTitles1D(hTAve2);
4242     hTAve2->Draw();
4243     //cTYield->SetLogy(1);
4244     gNAvePhi2->Draw("p");
4245     gAAvePhi2->Draw("p");
4246     gMAvePhi2->Draw("p");
4247     if(DrawFit)gNAvePhiFit2->Draw("p");
4248     if(DrawFit)gAAvePhiFit2->Draw("p");
4249     if(DrawFit)gMAvePhiFit2->Draw("p");
4250     sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
4251     keySymbol(.50,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
4252     keySymbol(.50,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
4253     keySymbol(.50,.75,"Underlying Event",ColorMin,MarkerMin,0.06,1.2*MarkerSize);
4254     if(DrawFit)keySymbol(.5,.70,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
4255     if(DrawFit)keySymbol(.5,.65,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
4256     if(DrawFit)keySymbol(.50,.6,"Underlying Event Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
4257     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);
4258     cTAve2->SaveAs(outName);
4259   }
4260 }